KatInterview

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

Coding Interview Problems

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

5978
Problems
2214
Auto-graded
15
Topics
272
Added today

Showing 151–180 of 2114 results

  • Data Structure DesignMediumAuto-graded
    Log Record Dedup: Batch Merge and Watermarked Replay

    Deduplicate log records by event id under a first or latest policy, then replay an operation list through a watermark-based stream deduplicator that drops late data and evicts finalized entries.

    Data Structure Designhash-mapsortingstreamingwatermark
  • Trees & GraphsMediumAuto-graded
    Indented Staff Listing from Direct-Report Pairs

    Build a forest from (employee, manager) pairs and output each person with their depth in a sorted depth-first order, handling very deep chains iteratively.

    Trees & Graphstreedfsforesthash-map
  • Trees & GraphsMediumAuto-graded
    Split a Nested Structure into Values and a Shape Template

    Implement a single function that extracts leaves and a shape template from nested lists and dicts, then rebuilds the original from them, testing recursion and traversal order.

    Trees & Graphsrecursiondfsnested-structuresdictionaries
  • Data Structure DesignHardAuto-graded
    Credit Ledger Simulator with Merges and Delayed Rewards

    Simulate a timestamped ledger with deposits, transfers, spends with delayed cashback, account merges and spend rankings, using union-find and a min-heap.

    Data Structure Designdesignunion-findheapsimulation
  • Arrays & HashingMediumAuto-graded
    Check Whether Two Custom Dice Give a Flat Sum Distribution

    Decide whether two lists of die-face labels make every total from 1 to 12 appear exactly three times across all 36 face pairings, using pair counting.

    Arrays & Hashingcountinghash-mapenumerationprobability
  • Math & Bit ManipulationMediumAuto-graded
    Growing Worker Pool Sized by Peak Load Readings

    Track a pool that only grows, sized to cover each load reading with fixed-capacity workers; tests ceiling division and running-maximum reasoning with large values.

    Math & Bit Manipulationsimulationprefix-maximumceiling-divisionarrays
  • Data Structure DesignMediumAuto-graded
    Expiring Key-Value Store Driven by a Virtual Clock

    Simulate a key-value store with per-key expiry on a manual clock, handling overwrites, deletes and cleanup of expired entries via a command list.

    Data Structure Designdesignhash-mapheapttl
  • Heaps, Sorting & SearchMediumAuto-graded
    Largest Threshold Met by Daily Step Counts

    Find the largest integer k such that at least k entries in a list are at least k, testing sorting or counting-based selection and reasoning about monotone thresholds.

    Heaps, Sorting & Searchsortingcountingh-indexarrays
  • Dynamic ProgrammingHardAuto-graded
    Adaptive Word Guessing Minimax Strategy

    Find the minimum number of worst-case letter guesses required to isolate a hidden word against an adversarial host.

    Dynamic Programmingdynamic-programmingbit-manipulationminimaxmemoization
  • Greedy & IntervalsMediumAuto-graded
    Peak Crew Size for Scheduled Shifts

    Compute the smallest crew that covers every scheduled task by finding the peak simultaneous demand, treating each task as half-open and parsing HH:MM times.

    Greedy & Intervalssweep-lineintervalsgreedysorting
  • Dynamic ProgrammingMediumAuto-graded
    Best Final Score from Affine Card Purchases Under a Budget

    Choose a budget-limited subset of cards and an order to maximize a score updated by an affine rule, testing subset and ordering search and exchange-argument reasoning.

    Dynamic Programmingsubset-searchpermutationsexchange-argumentknapsack
  • Heaps, Sorting & SearchMediumAuto-graded
    Truncate and Renormalize a Next-Token Distribution

    Sort a probability list with deterministic tie-breaking, then build two truncated, renormalized versions: fixed-size top-k and cumulative-mass top-p.

    Heaps, Sorting & Searchsortingprefix-sumprobabilityfloating-point
  • Heaps, Sorting & SearchMediumAuto-graded
    Locate a Value in a Cyclically Shifted Ascending List

    Search a cyclically shifted strictly increasing list of distinct integers for a value in O(log n), returning its index or -1, including unshifted and single-element cases.

    Heaps, Sorting & Searchbinary-searcharraysrotated-arraydivide-and-conquer
  • Stacks & QueuesMediumAuto-graded
    Infer Execution Events from Call Stack Snapshots

    Reconstruct chronological function START and END lifecycle events by evaluating structural differences across consecutive call stack snapshots.

    Stacks & Queuesstacks-queuesarraysstrings
  • Arrays & HashingEasyAuto-graded
    Group Identical Files by Content from an In-Memory Listing

    Group file entries that have identical byte content, using content length as a cheap first filter, and return only groups of two or more paths in a specified order.

    Arrays & Hashinghashinggroupingstringssimulation
  • Arrays & HashingMediumAuto-graded
    Tally Contiguous Segments Matching a Goal Total

    Count contiguous non-empty segments of an integer array whose sum equals a goal, using running totals and a frequency map to handle negatives and zeros in linear time.

    Arrays & Hashingprefix-sumhash-mapsubarraycounting
  • Greedy & IntervalsMediumAuto-graded
    Max Gains from Single and Multi-Trade Asset Strategies

    Calculate maximum achievable gain for an asset sequence under single-trade and unlimited-trade restrictions.

    Greedy & Intervalsarraysgreedydynamic-programming
  • Math & Bit ManipulationEasyAuto-graded
    Spread of a Number List: Population Variance

    Implement population variance on a list of numbers without external libraries, handling empty and single-element inputs and choosing a numerically sound approach.

    Math & Bit Manipulationvariancestatisticsfloating-pointarrays
  • Trees & GraphsEasyAuto-graded
    Distance Map to the Closest Exit in a Maze Grid

    Compute, for every cell of a grid with walls and exits, the fewest steps to the nearest exit, marking walls and cut-off cells as -1, using multi-source BFS.

    Trees & Graphsbfsgridmulti-source-bfsshortest-path
  • Arrays & HashingEasyAuto-graded
    Simulate Key-Value Operations

    Process a series of insertion, update, and deletion instructions on a key-value store and return the final contents ordered by key.

    Arrays & Hashingarraysstringshash-table
  • Heaps, Sorting & SearchMediumAuto-graded
    Stable Divide-and-Conquer Sort of an Integer List

    Sort a list of integers in ascending order without mutating the input, using a divide-and-conquer merge approach that guarantees O(n log n) time and linear auxiliary space.

    Heaps, Sorting & Searchsortingdivide-and-conquermerge-sortstability
  • Heaps, Sorting & SearchMediumAuto-graded
    Rank Selection Plus Longest Leave-Assisted Break

    Combines selecting the element at a 0-indexed rank in descending order with a sliding window finding the longest stretch containing at most a given number of workdays.

    Heaps, Sorting & Searchheapsliding-windowtwo-pointersorder-statistics
  • Heaps, Sorting & SearchMediumAuto-graded
    Identify Unique Zero-Sum Triples

    Find all distinct combinations of three elements in an integer sequence that sum to zero using two pointers and duplicate handling.

    Heaps, Sorting & Searcharraystwo-pointerssorting
  • StringsMediumAuto-graded
    Words Spelled by a Finger Trace Across Keys

    Find all dictionary words that fit a key trace as a start- and end-anchored subsequence where letters may reuse a key, using a next-occurrence table to match many words efficiently.

    Stringsstringssubsequencegreedyprecomputation
  • StringsMediumAuto-graded
    Resolve Nested %NAME% Placeholders with Cycle Detection

    Expand %NAME% placeholders whose values may reference other placeholders, handling %% escapes, missing names, and circular references.

    Stringsparsingdfsmemoizationcycle-detection
  • Dynamic ProgrammingMediumAuto-graded
    Counting Sorted Sequences With Prescribed Digit Sums

    Count non-decreasing sequences of integers in [0, 5000] whose i-th element has a given digit sum, using DP over candidate values with prefix sums, modulo 1,000,000,007.

    Dynamic Programmingdynamic-programmingprefix-sumstwo-pointerscounting
  • Greedy & IntervalsMediumAuto-graded
    Estimate Percentile from Histogram Buckets

    Linearly interpolate a percentile value across histogram buckets assuming uniform distribution within each interval.

    Greedy & Intervalsmathintervalshistogrampercentile
  • Data Structure DesignMediumAuto-graded
    Replay a Sequence of Recency-Evicting Cache Commands

    Simulate a fixed-capacity cache that evicts the least recently used entry, replaying a list of get/put commands and returning each command's result.

    Data Structure Designlru-cachehash-maplinked-listsimulation
  • Dynamic ProgrammingHardAuto-graded
    Fewest Cabinets for Two-Resource Jobs

    Group jobs with two resource demands into the fewest identical cabinets, using exact search with symmetry breaking and pruning (2D vector bin packing).

    Dynamic Programmingbin-packingbacktrackingbitmaskcombinatorial-optimization
  • Math & Bit ManipulationMediumAuto-graded
    Smallest Palindrome Above a Given Number

    Find the smallest palindromic integer strictly larger than a non-negative integer, using the left half of the digits and carry handling, including the all-9s case.

    Math & Bit Manipulationpalindromedigitsmathcarry