KatInterview

practice a little every day — you've got this ♡

Coding Interview Problems

Practice 6040 original coding, SQL, system design, machine learning and behavioral problems across 15 topics. Coding and SQL problems run against hidden test cases right in your browser; every problem has hints and a worked solution, free.

6040
Problems
2237
Auto-graded
15
Topics
275
Added today

Showing 1201–1230 of 2790 results

  • Trees & GraphsMediumAuto-graded
    Referral Credit Ledger with Multilevel Propagation

    Simulate account additions, referral bonus propagation (direct or indirect), and threshold queries ordered deterministically.

    Trees & Graphstrees-graphsarraysdesign-ds
  • Trees & GraphsMediumAuto-graded
    BFS Unweighted Shortest Path with Ancestor Tracking

    Perform breadth-first traversal on an unweighted graph to compute shortest distances and record parent pointers for path reconstruction.

    Trees & Graphsbfsgraph-traversalshortest-pathqueue
  • StringsMediumModel answer
    Fix a Buggy Python Table-to-CSV Function

    Audit a short Python function that flattens rows into CSV text, list its correctness and performance flaws with triggering inputs, and rewrite it safely and efficiently.

    Stringscode-reviewcsvpythonstring-building
  • Trees & GraphsMediumAuto-graded
    Lightest Downward Path in a Level-Order Tree

    Find the root-to-leaf path with the smallest value sum in a tree given as a level-order list, breaking ties toward the left, without recursion on 100,000-node skewed trees.

    Trees & Graphsbinary-treedfsiterative-traversalprefix-sum
  • Data Structure DesignMediumModel answer
    Build a Per-User Throttle and an In-Memory Event Broadcaster

    Write a thread-safe per-user token-bucket throttle and a small topic-based event broadcaster that stays correct under concurrency and survives failing listeners.

    Data Structure Designrate-limitingtoken-bucketpub-subconcurrency
  • Heaps, Sorting & SearchMediumAuto-graded
    Select the k Most Common Values with Tie Rules

    Count value frequencies and pick the k most frequent values, using a bounded heap and a defined tie-break rule for equal counts.

    Heaps, Sorting & Searchheaphash-mapfrequency-countingtop-k
  • Heaps, Sorting & SearchEasyAuto-graded
    Adjacent Entries Lookup in a Sorted Catalog

    Answer batched queries on a sorted list of unique IDs by binary searching for each target and returning its adjacent values, or nulls when the target is absent.

    Heaps, Sorting & Searchbinary-searchsorted-arraybisectbatch-queries
  • Heaps, Sorting & SearchEasyAuto-graded
    Locate Gap in Sorted Consecutive Sequence

    Detect a missing entry in a sorted contiguous array of integers in logarithmic time using binary search.

    Heaps, Sorting & Searcharraysbinary-search
  • Greedy & IntervalsMediumAuto-graded
    Find the Maximum Size Connected Interval Component

    Find the maximum number of intervals that belong to a single connected component where edges represent inclusive interval overlaps.

    Greedy & Intervalsintervalssortinggreedygraphs
  • Greedy & IntervalsEasyAuto-graded
    Split Chores Between Two Workers With a Fixed Quota

    Choose exactly k items for the first worker to maximize total payoff, which tests reducing a problem to per-item differences and greedy top-k selection.

    Greedy & Intervalsgreedysortingarraysexchange-argument
  • Data Structure DesignMediumModel answer
    Simulate Message Spreading in an Orbital Network

    Simulate timed, discrete-event message propagation across a satellite graph and fire report callbacks in exact time and ID order.

    Data Structure Designtrees-graphsheaps-sortingdesign-ds
  • Arrays & HashingEasyAuto-graded
    Softmax-Weighted Value Mixing for Query Rows

    Implement scaled dot-product attention on nested lists using a numerically stable softmax and a weighted average of value rows.

    Arrays & Hashingmatrixsoftmaxnumerical-stabilityattention
  • Arrays & HashingEasyAuto-graded
    Find the Modal Number, Smallest on a Tie

    Tests frequency counting with a hash map and a deterministic numeric tie-break, returning the value itself without altering the input list.

    Arrays & Hashinghash-mapcountingtie-breaking
  • Data Structure DesignMediumModel answer
    Build a Bounded, Thread-Safe Resource Pool with Timeouts

    Implement a thread-safe pool that lazily creates up to N connections, reuses healthy ones, blocks callers with a deadline when exhausted, and shuts down cleanly.

    Data Structure Designconcurrencythread-safetycondition-variableresource-pool
  • Data Structure DesignMediumAuto-graded
    Run a Command Log on a Recency Cache with Live Mean

    Simulate a fixed-capacity least-recently-used cache from a command log, answering lookups and the mean of stored values, each in expected constant time.

    Data Structure Designlru-cachehash-mapdoubly-linked-listrunning-sum
  • StringsMediumAuto-graded
    Every Window of Length Three or More Must Be a Known Word

    Check that every contiguous substring of length at least 3 appears in a word list, testing set-based lookups, loop bounds and the vacuous case for short strings.

    Stringsstringshash-setsubstringsenumeration
  • Data Structure DesignMediumModel answer
    Concurrent Least-Recently-Used Cache with Constant-Time Operations

    Build a fixed-capacity cache with O(1) lookup, update and eviction by recency, then make it safe for many threads and state exactly what consistency it guarantees.

    Data Structure Designlru-cachehash-mapdoubly-linked-listconcurrency
  • Data Structure DesignMediumAuto-graded
    Evaluate Nested Comparison Rules Over a List of Records

    Evaluate a nested rule tree of greater-than, less-than, AND and OR nodes against records, keeping matches in order and treating missing or mismatched fields as false.

    Data Structure Designrecursiontree-evaluationfilteringvalidation
  • StringsMediumAuto-graded
    Centered Pascal Pyramid Renderer

    Build the first n rows of Pascal's triangle and render them as a centered text pyramid with fixed-width, right-aligned cells and floor-based indentation.

    Stringspascal-trianglestring-formattingsimulationmath
  • Trees & GraphsMediumAuto-graded
    Read a Tree Off Column by Column from a Level-Order List

    Decode a level-order tree list, assign each node a column, and output values grouped by column with row-then-reading-order tie-breaking.

    Trees & Graphsbinary-treebfshash-maplevel-order
  • Trees & GraphsMediumAuto-graded
    Depth-Scaled Total of a Nested Integer Structure

    Traverse an arbitrarily nested list of integers and add up each value multiplied by how deeply it is nested, testing DFS/BFS traversal of recursive structures.

    Trees & Graphsdfsbfsnested-listsrecursion
  • Arrays & HashingMediumAuto-graded
    Merge Sensor Readings into Qualifying State Runs

    Group consecutive identical-state readings into runs, then keep only runs whose last-minus-first timestamp span meets a minimum threshold.

    Arrays & Hashingrun-lengthsingle-passsimulationgrouping
  • Data Structure DesignMediumModel answer
    Build an In-Memory Hierarchical File System with CRUD Support

    Design and implement an in-memory key-value store structured as a file system tree supporting create, set, get, and cascade delete operations with path validation.

    Data Structure Designdesign-dstrees-graphsstrings
  • Data Structure DesignMediumAuto-graded
    Simulate a Bounded Recency-Evicting Key-Value Store

    Replay a batch of get/put commands against a fixed-capacity store that discards its least recently used key on overflow, with O(1) average cost per command.

    Data Structure Designlru-cachehash-maplinked-listsimulation
  • Data Structure DesignHardModel answer
    Per-User Rolling Quota Gate with Concurrent Access

    Design a thread-safe class that caps how many requests each user may make in any trailing time interval, avoiding the burst problem of fixed windows, with sub-linear cost per check.

    Data Structure Designrate-limitersliding-windowdequeconcurrency
  • Data Structure DesignEasyAuto-graded
    Bunk Allocation by Preferred Room Size

    Match students to rooms by hard size preference in input order, respecting capacity, keeping partially filled rooms, and reporting students who could not be placed.

    Data Structure Designqueuessimulationhash-mapgreedy
  • Dynamic ProgrammingMediumAuto-graded
    Maximum Disjoint Triples Summing to 15

    Find the most disjoint three-card groups that each sum to 15, using memoized search over value counts because greedy choices can block better groupings.

    Dynamic Programmingmemoizationrecursioncombinatoricsstate-compression
  • Dynamic ProgrammingHardAuto-graded
    Best Profit from a Capped Number of Round-Trip Trades

    Maximize profit from daily share prices using at most k non-overlapping buy-then-sell trades, testing state-based dynamic programming and handling a trade limit that never binds.

    Dynamic Programmingdynamic-programmingarraysstock-tradingstate-machine
  • Data Structure DesignHardModel answer
    Escalation Counters and Level Changes in a Review Pipeline

    Design a cached repeat-alert counter that triggers rejection of a work order, then extend it so an alert's severity can change without corrupting counts or past decisions.

    Data Structure Designcachingidempotencyconcurrencyversioning
  • Dynamic ProgrammingMediumAuto-graded
    Most Populous Digit-Sum Group in a Number Range

    Count integers in a huge range grouped by digit sum and return the largest group size, which needs a digit DP with prefix-count subtraction rather than enumeration.

    Dynamic Programmingdigit-dpcountingrange-queriesmath