KatInterview

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

Coding Interview Problems

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

6048
Problems
2239
Auto-graded
15
Topics
272
Added today

Showing 1351–1380 of 2793 results

  • 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
  • Data Structure DesignHardModel answer
    Pattern Router for Sensor Topics with Placeholders and a Tail Wildcard

    Design a router that maps dot-separated topics to registered patterns with named placeholders and a trailing "**", using strict left-to-right precedence and backtracking.

    Data Structure Designtriebacktrackingroutingpattern-matching
  • 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 DesignMediumModel answer
    Live-Streaming Prompt Box with Incremental Reply Rendering

    Design and code a small front-end component that sends a prompt, renders a streamed reply as it arrives, blocks duplicate sends, supports cancel, and shows loading and error states.

    Data Structure Designfrontendreactstreamingasync-state
  • 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
  • StringsHardModel answer
    Ordered Index Pairs Whose Concatenation Reads the Same Backwards

    Given distinct lowercase words, list every ordered index pair whose concatenation is a palindrome, doing much better than checking all pairs.

    Stringspalindrometriehashingkmp
  • Data Structure DesignMediumModel answer
    Pointers vs References in C++: Semantics and API Design

    Contrast C++ raw pointers with references, choose the right parameter and return types for four trading-engine APIs, and explain how aliasing affects optimization.

    Data Structure Designcpppointersreferencesapi-design
  • 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
  • Data Structure DesignMediumModel answer
    Python Deep Dive: Concurrency, Generators, Typing and Memory

    Nine-part Python fundamentals review covering the GIL, concurrency models, decorators, generators, typing, packaging, profiling, memory management and exceptions.

    Data Structure Designpythongilconcurrencygenerators
  • Trees & GraphsHardModel answer
    Principal Types for a Tiny Lambda Calculus

    Build an AST for variables, lambdas and applications, then infer each expression's most general function type using unification, with an occurs check to reject infinite types.

    Trees & Graphstype-inferenceunificationhindley-milnerast
  • 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
  • Greedy & IntervalsEasyAuto-graded
    Best Single Buy-Sell Gain from Daily Quotes

    Find the largest gain from buying on one day and selling on a later day in a list of daily prices, returning 0 if no gain is possible.

    Greedy & Intervalsgreedyarraysrunning-minimumsingle-pass
  • Trees & GraphsMediumModel answer
    Tallying a Tree of Message-Passing Processes

    Each tree node is an isolated process with only async send and blocking receive. Design a protocol so the root learns the tree size, tolerates lost and duplicate messages, and returns a structured result.

    Trees & Graphsdistributed-systemsconvergecastidempotencyretries
  • Math & Bit ManipulationMediumModel answer
    Stable Softmax, Sliding Variance and Balanced Partition

    Three short coding tasks: an overflow-safe softmax, an O(1) sliding-window variance with a ring buffer, and splitting positive integers into two groups with the smallest sum gap.

    Math & Bit Manipulationsoftmaxnumerical-stabilitywelfordsliding-window
  • Math & Bit ManipulationEasyAuto-graded
    Annual Profit and Break-Even Value for a Lounge Menu Item

    Compute a per-site annual operating result and the break-even per-unit benefit from visit volume, uptake rate, unit cost, unit benefit, a one-time setup cost, and a time horizon.

    Math & Bit Manipulationarithmeticbreak-evensimulationedge-cases
  • Arrays & HashingMediumAuto-graded
    Mean Front-to-Rear Lens Flips Across Recorded Sessions

    Group event logs by session, sort chronologically, count adjacent front-then-rear transitions, and average over all sessions, including sessions with zero flips.

    Arrays & Hashinghash-mapgroupingsortingsimulation
  • Dynamic ProgrammingMediumAuto-graded
    Distinct Value Groups Summing to a Goal, Each Item Used Once

    Enumerate every distinct multiset of values from a list with repeats that adds up to a goal, using each position at most once, via sorted backtracking with duplicate skipping.

    Dynamic Programmingbacktrackingrecursionsortingcombinations
  • Heaps, Sorting & SearchEasyAuto-graded
    Closest Points to a Query Vector, Ranked with Index Tie-Break

    Select the k dataset points nearest to a query in n-dimensional space, ordered by distance, with ties resolved by smaller index.

    Heaps, Sorting & Searchk-nearest-neighborssortingheapeuclidean-distance
  • Arrays & HashingMediumModel answer
    Scoring Parsed Payroll Form Output Against Ground Truth

    Write a scorer that compares fields extracted from tax forms to a ground-truth mapping, normalizing keys and currency, then reporting match rate, missing and mismatched fields, and precision/recall.

    Arrays & Hashingdata-normalizationhash-mapsevaluation-metricsprecision-recall