KatInterview

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

Coding Interview Problems

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

6033
Problems
2234
Auto-graded
15
Topics
274
Added today

Showing 991–1020 of 2133 results

  • Stacks & QueuesMediumAuto-graded
    Evaluate Nested Prefix Expressions with Scoped Bindings

    Parse and evaluate a parenthesized prefix language with sum, prod and set, handling lexical scoping, strict validation and 32-bit overflow rules.

    Stacks & Queuesparsingrecursionscopingstack
  • Data Structure DesignMediumAuto-graded
    Subtree Totals Under Collapse and Graft Operations

    Maintain per-node totals in a rooted tree while nodes are collapsed into leaves or have a subtree grafted onto a leaf, answering total queries after each change.

    Data Structure Designtreehash-mapsimulationparent-pointers
  • Data Structure DesignMediumAuto-graded
    Alive-Node Graph Simulator with Gated Edge Insertion

    Simulate a sequence of node toggles, edge edits, and connectivity queries on an undirected graph where only alive nodes count and edges are only added between alive endpoints.

    Data Structure Designunion-findgraphsimulationconnected-components
  • Arrays & HashingEasyAuto-graded
    Share of Users Who Cancel and Never Come Back

    Group booking records by user, find each canceller's earliest cancellation, and compute the percentage with no later confirmed or returned booking.

    Arrays & Hashinghash-maptimestampsgroupingpercentage
  • Stacks & QueuesMediumAuto-graded
    Finish Times for a Single Worker with a Limited Waiting Line

    Simulate a one-worker FIFO queue with a capped waiting line and report each job's finish time or -1 if it was rejected, using a deque of finish times.

    Stacks & Queuesqueuedequesimulationamortized-analysis
  • Data Structure DesignMediumAuto-graded
    Nearest Working Charger: Command Simulator with Great-Circle Math

    Process a batch of commands on a charging-station registry, with status updates, spherical distance and nearest-online lookups that break ties deterministically.

    Data Structure Designdesignsimulationhaversinesorting
  • Arrays & HashingMediumAuto-graded
    Runner-Up Label by Frequency Tier in a Flat Record List

    Count labels in every third slot of a flat list, find the second-highest distinct count, and break ties by earliest appearance.

    Arrays & Hashinghash-mapcountingfrequencytie-breaking
  • Arrays & HashingEasyAuto-graded
    Locate Two Entries Adding Up to a Goal Value

    Find two different positions in an integer list whose values sum to a goal, using a deterministic tie-break rule, which tests complement lookup with a hash map.

    Arrays & Hashinghash-maparraycomplement-lookuptwo-sum
  • Data Structure DesignMediumAuto-graded
    Recency-Evicting Store Simulation Plus Graph Group Tally

    Simulate a fixed-size recency-evicting key-value store from a command log, and separately count connected groups in an undirected graph, returning both results together.

    Data Structure Designlru-cachehash-mapordered-dictunion-find
  • Math & Bit ManipulationMediumAuto-graded
    Four Weighted Dice: Lowest Three Add Up to Three

    Compute the exact reduced probability that the three smallest of four independent weighted dice sum to 3, which reduces to counting weighted outcomes with at least three ones.

    Math & Bit Manipulationprobabilitycombinatoricsfractionscounting
  • Math & Bit ManipulationMediumAuto-graded
    Project a Vertex and Its Normal Through a Render Pipeline

    Apply model, view and projection matrices to a point, do the perspective divide and viewport mapping, and transform a normal with the inverse-transpose of the model's 3x3 block.

    Math & Bit Manipulationlinear-algebramatriceshomogeneous-coordinatessimulation
  • Dynamic ProgrammingHardAuto-graded
    Full-String Matching with Dot and Star Wildcards

    Decide whether a whole text matches a pattern with '.' and '*' wildcards, using prefix-based dynamic programming over text and pattern positions.

    Dynamic Programmingdynamic-programmingstringspattern-matchingrecursion
  • Greedy & IntervalsMediumAuto-graded
    Minimum Removals for Conflict-Free Time Slots

    Tests the greedy earliest-finish strategy: find the fewest ranges to discard so the rest share no interior points, with touching endpoints allowed.

    Greedy & Intervalsgreedyintervalssortinginterval-scheduling
  • StringsEasyAuto-graded
    Decode an Ancient Numeral String into a Number

    Parse a valid Roman numeral string into its integer value by handling additive symbols and the six subtractive pairs.

    Stringsstringshash-mapparsingsimulation
  • Arrays & HashingMediumAuto-graded
    Merge Mutual Connections Into Earliest-Confirmed Pairs

    Tests normalizing undirected pairs, filtering pending rows, and keeping the earliest date per pair from a list of event dictionaries, with deterministic sorted output.

    Arrays & Hashinghash-mapgroupingnormalizationsorting
  • Linked ListsEasyAuto-graded
    Combine Two Ascending Sequences Into One

    Tests a two-pointer merge of two non-decreasing integer lists into a single sorted list, handling empty inputs and duplicate values correctly.

    Linked Liststwo-pointersmergesorting
  • StringsMediumAuto-graded
    Shrink Repeated Letters into Letter-Count Pairs

    Encode each maximal run of equal letters as the letter plus its decimal count, and fall back to the input when the encoding is not strictly shorter.

    Stringsstringstwo-pointersrun-length-encodingsimulation
  • Data Structure DesignMediumAuto-graded
    Subtree Earnings Ledger with Ranked Threshold Queries

    Simulate a command sequence on a referral forest, maintaining subtree revenue totals and answering ranked queries filtered by a strict threshold.

    Data Structure Designhash-maptreesimulationsorting
  • Trees & GraphsMediumAuto-graded
    Longest Dependency Chain in a Task DAG

    Find the longest total-duration chain in a task dependency DAG and return its length and task names, using topological-order DP with predecessor tracking.

    Trees & Graphsgraphdagtopological-sortdynamic-programming
  • Trees & GraphsMediumAuto-graded
    Acyclic Invitation Graph with Depth Queries and Expected Payout

    Simulate a stream of operations on a DAG: reject cycle-forming or duplicate edges, count nodes within a hop limit, and sum expected decayed payouts using BFS shortest distances.

    Trees & Graphsgraphbfsdagcycle-detection
  • StringsMediumAuto-graded
    Decode a Hex String into a Dotted-Quad Network Address

    Validate a strict 8-digit hex string with an optional 0x prefix and convert it into dotted-decimal IPv4 form, treating the leftmost byte as the first octet.

    Stringsstringsparsingvalidationhexadecimal
  • Heaps, Sorting & SearchMediumAuto-graded
    Running Median Over a Command Log of Inserts and Queries

    Process a log of insert and query commands on a growing multiset of integers, reporting the median at each query using two heaps for efficient updates.

    Heaps, Sorting & Searchheaptwo-heapsstreamingmedian
  • Stacks & QueuesMediumAuto-graded
    Self-Time Accounting for Nested Call Traces

    Use a stack to turn start/end trace records of nested calls on one CPU into each function's self-time, with inclusive end timestamps.

    Stacks & Queuesstackparsingsimulationstrings
  • Data Structure DesignMediumAuto-graded
    Replay Operations on a Skip-Ahead Iterator

    Simulate a forward-only iterator that yields every k-th element, with an idempotent has-next check, and return the results of a scripted sequence of operations.

    Data Structure Designiteratorsimulationstate-managementdesign
  • Heaps, Sorting & SearchEasyAuto-graded
    Rank Advertisers by Reports, Then Report Rate

    Aggregate per-ad records by advertiser, then rank with a multi-key sort (total reports, report rate, id) and return the top k.

    Heaps, Sorting & Searchhashingsortingaggregationcustom-sort-key
  • Dynamic ProgrammingMediumAuto-graded
    Maximum Ore Haul on a Climb-and-Step Grid Route

    Grid dynamic programming: find the route with the largest sum from the bottom-left to the top-right cell when only moving up or right.

    Dynamic Programmingdynamic-programminggridmatrixpath-sum
  • Greedy & IntervalsMediumAuto-graded
    Fewest Vehicles to Cover Back-to-Back Bookings

    Find the peak number of simultaneously active half-open intervals using a sweep line or heap, with correct handling of ties where one booking ends as another begins.

    Greedy & Intervalsintervalssweep-linesortingheap
  • Data Structure DesignMediumAuto-graded
    Parcel Runner Payout Ledger with Peak Overlap Queries

    Simulate a stateful ledger driven by operation lists: track per-runner payout sums and compute maximum simultaneous half-open intervals clipped to a query window.

    Data Structure Designsweep-linehash-mapintervalssimulation
  • Data Structure DesignMediumAuto-graded
    Batch Runner for a Slash-Separated Key Store

    Simulate a hierarchical key store from a batch of create/get commands, where a key can only be created once its parent key already exists.

    Data Structure Designdesignhash-maptriesimulation
  • Trees & GraphsMediumAuto-graded
    Job Scheduling with Cycle Check and Downstream Rerun Set

    Topologically sort jobs with cycle detection, then use graph reachability to find all jobs affected by changed ones and list them in valid order.

    Trees & Graphstopological-sortgraphbfscycle-detection