KatInterview

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

Interview Practice Problems

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

6036
Problems
2235
Auto-graded
15
Topics
273
Added today

Showing 1111–1140 of 2235 results

  • Dynamic ProgrammingMediumAuto-graded
    Counting Valid Ordered Binary Trees on n Labeled Nodes

    Count the distinct binary search trees on keys 1..n by splitting on the root and combining independent subtree counts with dynamic programming.

    Dynamic Programmingdynamic-programmingcombinatoricsbinary-search-treecatalan-numbers
  • Math & Bit ManipulationHardAuto-graded
    Can a Starting Pair Grow Into a Goal Pair by Summing Coordinates?

    Decide whether a goal pair is reachable from a start pair by replacing one coordinate with the sum of both, using a reverse walk with Euclid-style modulo jumps for values up to 10^9.

    Math & Bit Manipulationmatheuclidean-algorithmreverse-thinkingmodulo
  • Stacks & QueuesMediumAuto-graded
    Rebuild an Outline Tree from Depth-Tagged Lines

    Turn a flat sequence of (depth, label) entries into a nested tree by attaching each entry to its nearest earlier entry with a smaller depth, using a monotonic stack.

    Stacks & Queuesstacktree-constructionparsingmonotonic-stack
  • Math & Bit ManipulationHardAuto-graded
    Fewest Presses to Morph One Light Grid Into Another

    Find the smallest set of cell presses that turns one on/off grid into another, where each press flips a cell and its neighbours. Tests GF(2) elimination and null-space minimisation.

    Math & Bit Manipulationgaussian-eliminationgf2bitmasklinear-algebra
  • Arrays & HashingEasyAuto-graded
    Filter Events per Subscriber with Named Rules

    Apply an ordered list of named filter rules to every user-event pair and build a per-user list of qualifying event ids, handling missing prices, empty rule lists and unknown rule names.

    Arrays & Hashinghash-mapsimulationfilteringstrategy-pattern
  • Arrays & HashingEasyAuto-graded
    Leftmost Column Containing a One in Row-Sorted Grid

    Find the leftmost column holding a 1 in a binary grid whose rows are sorted, aiming for a linear-time walk instead of scanning every cell.

    Arrays & Hashingmatrixtwo-pointersbinary-matrixstaircase-search
  • Arrays & HashingMediumAuto-graded
    Weekly Power-User Share per Country from Impression Logs

    Group impression records by country and user over a 7-day window, flag users with 4+ active dates and 3+ surfaces on one date, and report per-country percentages.

    Arrays & Hashinghash-mapgroupingsetsdate-handling
  • Trees & GraphsMediumAuto-graded
    Best Island Total with Row-Major Boundary Cells

    Find connected components in a signed grid and pick the best-scoring one, with and without a no-negatives rule, reporting its first and last row-major cells.

    Trees & Graphsgriddfsconnected-componentstie-breaking
  • Data Structure DesignMediumAuto-graded
    Live Ranking Board for Sponsored Listings

    Process a batch of insert, delete and top-k operations on scored items, keeping a live ranking with in-place score updates and deterministic tie-breaking.

    Data Structure Designheaphash-maplazy-deletiondesign
  • Data Structure DesignEasyAuto-graded
    Ledger Replay: Deposits, Withdrawals and Percentage Rewards

    Simulate a single account balance across a sequence of operations, silently rejecting invalid ones, and report the balance after each step.

    Data Structure Designsimulationstate-managementvalidationfloating-point
  • Trees & GraphsMediumAuto-graded
    Costliest Root Task in a Task Forest

    Sum durations over each root's subtree in a parent-linked record list and return the root with the largest total, testing tree aggregation and iterative traversal.

    Trees & Graphstreedfshash-mapiterative-traversal
  • SQL & DataMediumAuto-graded
    Top Two Spending Categories per Shopper with Share of Spend

    Aggregate line-item spend by shopper and category, rank with ties, keep the top two ranks, add spend share, and handle shoppers with no purchases.

    SQL & Dataaggregationgroupingrankingjoins
  • Dynamic ProgrammingMediumAuto-graded
    Longest Shared Block After Removing One Character

    Find the longest block shared with a second string after optionally deleting one character from the first, using an O(n*m) DP with a deletion-used state.

    Dynamic Programmingdynamic-programmingstringslongest-common-substring
  • Data Structure DesignMediumAuto-graded
    Nested Message Schema: Size and Field Type Queries

    Parse a mini protobuf-style schema from text, then answer batched size and field-type queries with nested messages, forward references, and cycle and error handling.

    Data Structure Designparsinghash-maprecursionmemoization
  • Trees & GraphsMediumAuto-graded
    Best Conversion Product Over Simple Currency Paths

    Find the largest product of edge weights over simple directed paths between two nodes, using backtracking DFS, with a special case for identical endpoints and an unreachable case.

    Trees & Graphsgraphdfsbacktrackingsimple-paths
  • StringsMediumAuto-graded
    Find a Block Repeated Back-to-Back in a Token List

    Decide whether a list of tokens contains a block of a given length repeated a given number of times in a row, testing period detection with a linear scan.

    Stringsstringsarrayssliding-windowperiodicity
  • Trees & GraphsMediumAuto-graded
    Net Access Letters Across a Dependency Hierarchy

    Compute each node's final letter set in a DAG where grants flow to all descendants but revocations apply only to the node that declares them.

    Trees & Graphsgraphdagtopological-sortbitmask
  • Data Structure DesignEasyAuto-graded
    Sorted Buffer Simulator with Insert and Snapshot Commands

    Simulate a container that keeps integers in ascending order under insert and snapshot commands, testing binary-search insertion, duplicate handling, and copying versus aliasing.

    Data Structure Designbinary-searchsimulationsorted-listdesign
  • Arrays & HashingMediumAuto-graded
    Shortest Block to Cut for a Non-Decreasing Remainder

    Find the shortest contiguous block whose removal leaves a non-decreasing array, using sorted prefix/suffix boundaries and two pointers, with a smallest-start tie-break.

    Arrays & Hashingtwo-pointersarraysprefix-suffixgreedy
  • Math & Bit ManipulationEasyAuto-graded
    Smallest Equicorrelation Value for a Valid 3x3 Matrix

    Determine the least real parameter for which a 3x3 symmetric matrix with unit diagonal and equal off-diagonal entries is positive semidefinite, using eigenvalue or minor analysis.

    Math & Bit Manipulationlinear-algebraeigenvaluespositive-semidefinitemath
  • Arrays & HashingMediumAuto-graded
    Cross-Array Pair Sum Check on Two Ordered Lists

    Decide whether one value from each of two sorted lists adds up to a target, using a linear-time opposite-direction two-pointer scan with constant extra space.

    Arrays & Hashingtwo-pointerssorted-arraystwo-sumoverflow-safety
  • Arrays & HashingEasyAuto-graded
    Horvitz-Thompson Event Rate from Weighted Inspection Records

    Estimate a population-wide event rate from samples drawn with known unequal inclusion probabilities, using inverse-probability weighting divided by the population size.

    Arrays & Hashinginverse-probability-weightingsamplingestimationhorvitz-thompson
  • Arrays & HashingMediumAuto-graded
    Rover on a Walled Floor Plan with Blocked Cells

    Simulate a rover on a bounded rectangular grid that turns, steps forward, and steps backward, skipping any step that leaves the grid or enters a blocked cell.

    Arrays & Hashingsimulationhash-setgridmodular-arithmetic
  • Greedy & IntervalsMediumAuto-graded
    Stock Piles Priced by Remaining Count: Maximum Earnings

    Greedy selling from the largest pile, solved in bulk with sorting and arithmetic-series sums because the number of sales is too large to simulate one by one.

    Greedy & Intervalsgreedysortingarithmetic-seriesmath
  • Arrays & HashingMediumAuto-graded
    Balanced Alternating Sums After One Removal

    Count positions whose removal makes the sum at even positions equal the sum at odd positions, testing prefix/suffix sums and the parity shift after a deletion.

    Arrays & Hashingprefix-sumsparityarraycounting
  • Data Structure DesignMediumAuto-graded
    Dual-Quota Request Throttle with Sliding Time Window

    Simulate a throttle that enforces a per-user and a per-game quota over a sliding time window, recording a request only when both quotas have room.

    Data Structure Designsliding-windowdequehash-mapsimulation
  • Trees & GraphsMediumAuto-graded
    Batch Ratio Lookup Over Linked Quantities

    Answer many ratio queries between named quantities from pairwise ratio facts, using a weighted union-find or component precomputation instead of a search per query.

    Trees & Graphsunion-findgraphweighted-union-findbatch-queries
  • Arrays & HashingEasyAuto-graded
    Category Revenue and Fulfillment Report from Three Tables

    Join order, product and category records, group by category name, and compute total revenue, mean revenue per row and the share of completed rows, using hash maps.

    Arrays & Hashinghash-mapaggregationjoingrouping
  • StringsMediumAuto-graded
    Build an expression from 1 to 9 that hits a target

    Tests depth-first backtracking over operator choices, on-the-fly evaluation without re-parsing, and deterministic tie-breaking when several valid answers exist.

    Stringsbacktrackingdfsrecursionstring-construction
  • Heaps, Sorting & SearchEasyAuto-graded
    Clean, Impute and Rank Student Score Records

    Filter records with too many missing values, fill gaps with per-subject medians, then pick the top five using a multi-key sort with tie-breaks.

    Heaps, Sorting & Searchsortingmediandata-cleaningsimulation