KatInterview

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

Coding Interview Problems

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

6035
Problems
2235
Auto-graded
15
Topics
274
Added today

Showing 1021–1050 of 2134 results

  • 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
  • Greedy & IntervalsMediumAuto-graded
    Sequential Allow/Deny Rules Over an IPv4 Block

    Track an IPv4 block as disjoint integer intervals while applying ordered allow and deny CIDR rules, deciding whether the block ends up fully covered with no deny hit.

    Greedy & Intervalsintervalsipv4cidrsimulation
  • Data Structure DesignMediumAuto-graded
    Healthy Region Registry and Nearest-Site Router

    Simulate a command interpreter that registers sites, toggles their health, and answers nearest-healthy-site queries by great-circle distance, with strict validation and tie-breaking.

    Data Structure Designsimulationstring-parsinghash-mapvalidation
  • Arrays & HashingEasyAuto-graded
    Yearly Account Balance with Conditional Monthly Service Charges

    Simulate a year of account activity, applying a flat monthly charge unless a month has enough payments with a large enough total, and return the final balance.

    Arrays & Hashingsimulationhash-mapaggregationconditional-logic
  • Greedy & IntervalsMediumAuto-graded
    Courier Earnings from Overlapping Order Events

    Sweep over unsorted start/end events to total concurrency-weighted seconds, validate malformed input, and convert to a half-up rounded dollar string.

    Greedy & Intervalsinterval sweepevent sortingvalidationexact arithmetic
  • Data Structure DesignEasyAuto-graded
    Most Likely Follower Lookup Over Streaming Sentences

    Process a stream of add and query operations over sentences, tracking adjacent-word counts and returning the most frequent follower with lexicographic tie-breaking.

    Data Structure Designhash-mapstringssimulationcounting
  • StringsEasyAuto-graded
    Report SQL Clauses in Conceptual Evaluation Order

    Detect which of six SQL clauses appear in a query string and return them in SQL-92 logical evaluation order, using case-insensitive whole-word matching.

    Stringsstringsregexsqlparsing
  • StringsMediumAuto-graded
    Mask the Leftmost Longest Keyword in a Text

    Find the earliest-starting match among several keywords, prefer the longest at that spot, and collapse it into a single placeholder character.

    Stringsstringsstring-matchingsimulationtrie
  • Heaps, Sorting & SearchMediumAuto-graded
    Replay Commands to Track a Running Median

    Replay a list of insert and query commands on a growing multiset of integers, reporting the median at each query; tests two-heap or order-statistic maintenance.

    Heaps, Sorting & Searchheapstreamingmediandesign
  • Data Structure DesignMediumAuto-graded
    Weighted Prefix Suggestion Engine via Command Replay

    Replay a list of add and search commands on a weighted word store, returning the top-k prefix matches ranked by weight, then alphabetically.

    Data Structure Designtrieprefix-searchheaphash-map
  • Math & Bit ManipulationMediumAuto-graded
    Chance of a Red Majority When Skipping Returned Marbles

    Compute a probability for a draw process with discarded-and-returned items by reducing it to a hypergeometric count, ignoring the irrelevant returned category.

    Math & Bit Manipulationprobabilitycombinatoricshypergeometricmath
  • Trees & GraphsHardAuto-graded
    Fewest Rounds to Slay a Scripted Boss With One Revive

    Find the minimum number of rounds to defeat a boss that attacks on a repeating script, using state-space BFS over boss HP, player HP, revive flag, and script position.

    Trees & Graphsbfsstate-space-searchsimulationshortest-path
  • Data Structure DesignMediumAuto-graded
    Replay a Log on a Budgeted Recency Cache

    Simulate a least-recently-used cache whose budget is the sum of per-entry sizes, replaying an operation log and returning each result, using hashing plus recency ordering.

    Data Structure Designlru-cacheordered-dicthash-mapsimulation
  • Trees & GraphsMediumAuto-graded
    List Every Non-Repeating Route in a Directed Graph

    Enumerate all routes from a source to a target in a directed graph that never revisit a node, returned in lexicographic order, using backtracking DFS.

    Trees & Graphsgraphdfsbacktrackingrecursion
  • Trees & GraphsMediumAuto-graded
    Left-Packed Tree Check from a Level-Order Array

    Decide whether a binary tree given as a level-order array with None placeholders is complete, by rebuilding it and scanning breadth-first for a node that follows a gap.

    Trees & Graphsbinary-treebfslevel-ordertree-construction
  • Arrays & HashingMediumAuto-graded
    Forced Winner in Complete and Incomplete Card Hands

    Rank five-card hands with a tuple key, then decide whether an outcome is forced across all ways to fill in missing cards.

    Arrays & Hashingsimulationcombinatoricscountingtie-breaking
  • Trees & GraphsMediumAuto-graded
    Open One Wall to Speed Up Multi-Source Spread

    Use multi-source BFS and brute force over single wall removals to minimize the time until every target is reached, with strict-improvement tie-breaking.

    Trees & Graphsbfsgridmulti-source-bfsbrute-force
  • Stacks & QueuesMediumAuto-graded
    Checkout Totals After Next Cheaper Coupon Item

    Find, for each element, the nearest later value that is less than or equal to it and subtract it, which tests monotonic stack reasoning on arrays.

    Stacks & Queuesmonotonic-stackarraysnext-smaller-element
  • Data Structure DesignMediumAuto-graded
    Fleet Billing Ledger With Time-Dated Per-Minute Rates

    Simulate a bike-fleet billing ledger where each ride is priced at the rate active at its start, with rate changes, duplicate ride ids and an exact total.

    Data Structure Designdesignsimulationbinary-searchdecimal-arithmetic
  • Math & Bit ManipulationEasyAuto-graded
    Feed Ad Load: Random Slots vs. Fixed Block Quota

    Compute expected ad counts for two feed ad policies and the chance of seeing at least one ad in a window, using linearity of expectation and the complement rule.

    Math & Bit Manipulationprobabilityexpectationmathcomplement-rule
  • Data Structure DesignMediumAuto-graded
    Three Mini Simulations: Case Folding, Aligned Allocator, Run Counter

    Solve three independent simulations: case-insensitive adjacent changes, an 8-aligned memory allocator, and online counting of same-color runs on a line.

    Data Structure Designsimulationstringshash-mapstate-maintenance
  • Data Structure DesignMediumAuto-graded
    Square Grid Line-Completion Referee

    Process a batch of moves on an n x n two-player grid and report after each move whether the mover has completed a full row, column, or diagonal, using constant-time per-move bookkeeping.

    Data Structure Designdesignsimulationcountingmatrix
  • Trees & GraphsMediumAuto-graded
    Surviving Tree Height and Extra Removals to Meet a Limit

    Compute the height of a tree after removing marked nodes (cutting off their subtrees), then find the fewest extra removals needed to bring the height within a limit.

    Trees & Graphstreedfsiterative-traversalheight
  • Data Structure DesignMediumAuto-graded
    LRU Store with Rolling Mean Over Recent Writes

    Simulate a batch of operations on an LRU key-value store that also tracks a rolling mean of the last k written values, with O(1) per operation.

    Data Structure Designlru-cachehash-mapdequesliding-window
  • Greedy & IntervalsMediumAuto-graded
    Emptying Depots With a Limited Pool of Partner Skips

    Compute the minimum skips each depot needs using modular arithmetic, then greedily pick the cheapest depots under a shared skip budget to maximize emptied depots.

    Greedy & Intervalsgreedymathsortingmodular-arithmetic
  • Trees & GraphsMediumAuto-graded
    Two-Choice Clinic Booking: Can Everyone Get a Slot?

    Decide whether each patient can get one of their two acceptable slots with no slot reused, by modelling slots as graph vertices and patients as edges.

    Trees & Graphsunion-findgraph-modelingmatchingconnected-components
  • Data Structure DesignEasyAuto-graded
    Replay Ledger Commands on a Guarded Account

    Simulate an account that processes a list of deposit, withdraw, balance and history commands, rejecting invalid amounts and overdrafts while recording only successful transactions.

    Data Structure Designsimulationclass-designstate-managementvalidation
  • Math & Bit ManipulationMediumAuto-graded
    Tie-Aware Ranking Probabilities for Three and Four Tasters

    Derive conditional ranking probabilities for i.i.d. scores, with and without ties, and return them as a dictionary keyed by named quantities.

    Math & Bit Manipulationprobabilitycombinatoricsconditional-probabilityclosed-form
  • Arrays & HashingEasyAuto-graded
    Triple Array Toolkit: Lookup, Increment, Zero Shift

    Combines a binary search on a sorted list, adding one to a digit-array number with carry, and a stable in-place move of zeros to the back.

    Arrays & Hashingbinary-searchtwo-pointerscarryin-place
  • Trees & GraphsEasyAuto-graded
    Reporting Chain Length Between Two Employees

    Find the number of links on the path between two people in a company tree given as pairs, which tests undirected graph modeling and BFS or lowest common ancestor reasoning.

    Trees & Graphsgraphbfstreeshortest-path