KatInterview

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

Coding Interview Problems

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

6049
Problems
2239
Auto-graded
15
Topics
272
Added today

Showing 1411–1440 of 2793 results

  • 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
  • Math & Bit ManipulationMediumModel answer
    Bit-Level Speedups for a Hot Integer Loop

    Choose bit-twiddling techniques that cut branch mispredictions and memory traffic in a tight integer loop, justify their correctness, and reason about their CPU and cache effects.

    Math & Bit Manipulationbit-manipulationbranchlesspopcountperformance
  • 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
  • Data Structure DesignMediumModel answer
    Fixing a Lost-Update Race in a Deposit Method You Cannot Edit

    Diagnose the race in an account deposit that reads, pauses, then writes, and add locking through a subclass, wrapper or embedding in Python and Go without touching the original type.

    Data Structure Designconcurrencyrace-conditionmutexpython
  • 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
  • Data Structure DesignMediumAuto-graded
    Bidirectional Walk Over a CIDR Block's Addresses

    Simulate a two-way cursor over the IPv4 addresses of a CIDR block using integer arithmetic, with exact boundary and no-move-on-failure rules.

    Data Structure Designiteratorbit-manipulationcidrsimulation
  • Data Structure DesignHardModel answer
    Retroactive Pay Ledger with Rate Changes and Shift Logging

    Design a class that records rate changes and shifts in any order, and reports total earnings under the current rate schedule using prefix sums and binary search.

    Data Structure Designdesignprefix-sumbinary-searchintervals
  • Data Structure DesignMediumModel answer
    Org Chart Inference with Manager and Peer Links

    Design a structure that records manager and same-manager links between employee IDs and answers whether one employee sits above another, including facts inferred from earlier updates.

    Data Structure Designunion-finddesigngraphstransitive-closure
  • Arrays & HashingMediumAuto-graded
    Card Authorization Report with Time-Activated Block Rules

    Sort card authorization events by time and apply permanent, time-activated block rules to label each as APPROVE or REJECT, testing stable sorting, two-stream merging and hashing.

    Arrays & Hashinghashingsortingsimulationtwo-pointers
  • Data Structure DesignMediumAuto-graded
    Count Lower Readings in a Trailing Time Window

    Simulate a sequence of record and query operations over a timestamped stream, counting readings in a trailing window that are strictly lower than the latest reading.

    Data Structure Designsliding-windowbinary-searchsimulationstreaming
  • Heaps, Sorting & SearchMediumAuto-graded
    Gini Split Search Plus One Regression Gradient Step

    Sweep sorted feature values to find the lowest weighted-Gini binary split, and apply one MSE gradient descent update for linear regression.

    Heaps, Sorting & Searchsortingprefix-sweepgini-impuritygradient-descent
  • Trees & GraphsMediumAuto-graded
    Largest Chain Reaction From a Single Detonation

    Model one-way blast reach as a directed graph and find the largest set reachable from any single starting node, using exact integer distance checks.

    Trees & Graphsgraphdfsreachabilitygeometry
  • Arrays & HashingMediumModel answer
    Merging k Key-Value Maps: Conflict Rules and Efficient Design

    Design a way to merge two key-value maps, extend it to k maps, and decide which conflict rules must be pinned down before writing any code.

    Arrays & Hashinghash-mapmergingapi-designclarifying-questions
  • Trees & GraphsMediumAuto-graded
    Find the Exit of a Keyed Forest Graph

    Run a breadth-first search over (location, keys held) states in a forest with locked doors to find the first exit reached, or None.

    Trees & Graphsbfsgraphstate-space-searchparsing
  • Greedy & IntervalsMediumAuto-graded
    Collapse Overlapping Time Ranges Into Disjoint Blocks

    Sort closed integer ranges and sweep once to combine any that overlap or touch, returning the minimal ordered list of disjoint ranges.

    Greedy & Intervalsintervalssortingsweepgreedy