KatInterview

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

Coding Interview Problems

Practice 6041 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.

6041
Problems
2237
Auto-graded
15
Topics
275
Added today

Showing 1231–1260 of 2790 results

  • Trees & GraphsMediumAuto-graded
    Cheapest Edit Count to Turn a Tree into a Perfect Tree

    Find the minimum number of leaf deletions and node insertions that make a binary tree perfect, using per-level counts and a bounded search over the target height.

    Trees & Graphsbinary-treebfslevel-ordermath
  • Trees & GraphsMediumAuto-graded
    Recover the Preorder of a BST from Its Postorder Listing

    Turn the postorder listing of a distinct-valued BST into its preorder listing in linear time, including chain-shaped trees, using a monotonic stack over the reversed input.

    Trees & Graphsbinary-search-treemonotonic-stacktree-traversalreconstruction
  • Math & Bit ManipulationEasyModel answer
    Timed Reasoning Quiz: Sequences, Cycles and Grammar Gaps

    Answer three short reasoning items (number sequence, repeating symbols, sentence completion) and explain a time-boxed strategy for a 50-item, 15-minute screen with no wrong-answer penalty.

    Math & Bit Manipulationaptitudepattern-recognitionmodular-arithmetictime-management
  • Trees & GraphsMediumModel answer
    Traverse a Concurrent Dependency Graph with Rate Control and Retries

    Discover the full transitive dependency graph of a package using sequential BFS and concurrent worker pools with retry handling and exact termination logic.

    Trees & Graphstrees-graphsdesign-dsstacks-queuesconcurrency
  • Arrays & HashingMediumAuto-graded
    Widest Window With an Exact Total in a Signed Sequence

    Find the longest contiguous run in an integer list (negatives and zeros allowed) whose total equals a target, using prefix sums and a hash map of earliest positions.

    Arrays & Hashingprefix-sumhash-mapsubarray
  • StringsMediumAuto-graded
    Even-Width Paragraph Formatter

    Greedily pack words into lines of a fixed width, then pad each line with spaces so it is exactly that wide, handling single-word and final lines separately.

    Stringsstringsgreedysimulationtext-justification
  • Math & Bit ManipulationMediumAuto-graded
    Calculate Promotion Break-Even for Rental Discount

    Compute the break-even target for new customer acquisitions under base and spend-uplift promotional scenarios.

    Math & Bit Manipulationmathunit-economicsfinancial-modeling
  • StringsMediumAuto-graded
    Check Whether a Token Is a Well-Formed Decimal Literal

    Scan a string once to decide if it matches a small decimal-literal grammar with optional sign, a dotted mantissa and an optional exponent, handling many edge cases.

    Stringsstring-parsingstate-machinevalidationedge-cases
  • Heaps, Sorting & SearchEasyAuto-graded
    Rank Top Earners Worldwide After Converting to USD

    Merge several lists of employee records, convert each salary to USD using a rate map, and return the top N earners with a deterministic tie-break.

    Heaps, Sorting & Searchsortinghash-mapdata-manipulationsimulation
  • Trees & GraphsMediumAuto-graded
    Reachable Vaults and Weighted Bracket Nesting Score

    Combine graph reachability from a start node with computing a nesting-weighted score of a balanced bracket string, returning both results as a pair.

    Trees & Graphsgraph-traversaldfsstringsparentheses
  • Data Structure DesignMediumModel answer
    Design an Extensible Boolean Rule Evaluation Engine

    Construct an object-oriented expression tree for logical and comparison operations that evaluates safely against context dictionaries with short-circuiting.

    Data Structure Designobject-oriented-designtreecomposite-patternevaluation-engine
  • Arrays & HashingHardAuto-graded
    Reachable Smallest Missing Values After a Single Increment

    Find every possible smallest-missing value of an array after at most one capped +1 edit, using counting and MEX case analysis in linear time.

    Arrays & Hashingmexcountingcase-analysisfrequency-array
  • Linked ListsMediumModel answer
    Unlink From the Tail and Prune a Tree by Leaf Swap

    Two pointer-manipulation tasks: remove the k-th node from the tail of a singly linked list, and delete a value from a general binary tree by overwriting it with the deepest-rightmost node's value.

    Linked Listslinked-listtwo-pointersbinary-treebfs
  • Math & Bit ManipulationEasyAuto-graded
    Compute Precision and Recall from Confusion Counts

    Compute precision and recall from the four confusion-matrix counts of a binary classifier, returning 0.0 for a metric whose denominator is zero.

    Math & Bit Manipulationmathconfusion-matrixprecision-recalledge-cases
  • Dynamic ProgrammingMediumAuto-graded
    Longest Shared Run Between Two Integer Lists

    Find the longest block of consecutive values common to two integer lists, and report its length and the smallest pair of start positions, using dynamic programming over suffix matches.

    Dynamic Programmingdynamic-programmingarrayssubarraytie-breaking
  • Arrays & HashingMediumAuto-graded
    Check a Partially Filled Number Grid for Rule Violations

    Scan a 9x9 digit grid once and decide whether any row, column, or 3x3 block repeats a digit, using per-group bitmasks or sets.

    Arrays & Hashinghashingbitmaskmatrixsimulation
  • StringsMediumAuto-graded
    Boxed Multi-Width Paragraph Formatter

    Greedily word-wrap each paragraph to its own width, then frame all resulting lines in one padded ASCII box sized by the widest paragraph limit.

    Stringsstringssimulationgreedytext-formatting
  • StringsMediumAuto-graded
    Squash Consecutive Letter-Rearrangement Duplicates

    Scan a word list and drop each word that is a letter rearrangement of the previously kept word, testing signature comparison and order-preserving single-pass filtering.

    Stringsstringsanagramssimulationtwo-pointers
  • Arrays & HashingMediumAuto-graded
    Maximum Score Level Backed by Enough Servers

    Find the largest k such that at least k scores are k or higher, using counting with capped values to reach linear time.

    Arrays & Hashingcountingh-indexbucketarrays
  • Arrays & HashingMediumAuto-graded
    Confirmed Connections from Invites and Replies

    Match reply events to earlier directed invites, normalize each user pair, and keep the earliest valid reply date per pair, sorted by pair.

    Arrays & Hashinghash-mapgroupingdeduplicationdates
  • Arrays & HashingMediumAuto-graded
    Most Common Item Pair Across Shopping Baskets

    Find the two products that appear together in the most orders, handling duplicate lines, mirrored pairs, ties, and orders with fewer than two distinct products.

    Arrays & Hashinghash-mapcombinationscountinggrouping
  • Data Structure DesignMediumAuto-graded
    Command-Driven Ledger with Transfer Volume Leaderboard

    Simulate an in-memory ledger from text commands, with validated transfers and a leaderboard ranked by outgoing volume with an alphabetical tie-break.

    Data Structure Designhash-mapsimulationsortingstring-parsing
  • Arrays & HashingMediumModel answer
    Solving Multi-Task Online Assessment Challenges

    A guide to solving four standard assessment tasks: cumulative running totals, step-by-step array reduction, deterministic matrix block placement, and linear arithmetic series optimization.

    Arrays & Hashingarrayssimulationgridoptimization
  • Data Structure DesignMediumModel answer
    Build an In-Memory Store with Nested Transactions and Value Counts

    Design a string key-value store with transactional writes, fast rollback, and a count of keys holding a given value, with all transaction semantics spelled out.

    Data Structure Designhash-maptransactionsundo-logdesign
  • StringsEasyAuto-graded
    Keypad Digit Sequence Word Filter

    Filter a word list down to the words whose letters, read through a phone keypad, spell out a given digit string, in original order.

    Stringsstringshash-mapfilteringsimulation
  • Data Structure DesignMediumAuto-graded
    Simulate a Topic Message Broker with Subscription Tokens

    Simulate a topic-based message broker from a command log, handling token issuance, ordered delivery records, and idempotent unsubscribes.

    Data Structure Designdesignhash-mapsimulationordering
  • Stacks & QueuesMediumAuto-graded
    Rebuild Call Start/Stop Events from Stack Snapshots

    Diff consecutive call-stack snapshots by longest common prefix to produce correctly ordered start and end events, including recursion, empty stacks and final closing.

    Stacks & Queuesstacksimulationlongest-common-prefixarrays
  • Linked ListsMediumAuto-graded
    Flip Every Block of K Consecutive Values in a Sequence

    Reverse each full consecutive block of k elements in a list of values, leaving a short trailing remainder untouched, using the pointer-based linked-list technique.

    Linked Listslinked-listin-placepointerssimulation
  • Data Structure DesignMediumModel answer
    In-Memory Calendar Service and Interval Queries

    Design and implement an in-memory calendar event service with full CRUD operations, validation rules, conflict detection, and unit testing strategy.

    Data Structure Designdesignintervalscrudvalidation
  • Data Structure DesignMediumModel answer
    Design a Weighted Sampling Generator with Dynamic Updates

    Implement a class for weighted sampling that supports O(1) sampling for static inputs and logarithmic updates for dynamic environments.

    Data Structure Designdesign-dsheaps-sortingmath-bits