KatInterview

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

Coding Interview Problems

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

6025
Problems
2231
Auto-graded
15
Topics
272
Added today

Showing 931–960 of 2130 results

  • 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 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 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
  • 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
  • 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
  • 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
  • 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
  • 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
  • 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