KatInterview

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

Coding Interview Problems

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

6027
Problems
2232
Auto-graded
15
Topics
272
Added today

Showing 1171–1200 of 2131 results

  • Arrays & HashingMediumAuto-graded
    Reconcile Payments Against Open Invoices in Three Tiers

    Process payments in order, pairing each with an invoice by ID plus amount, then by unique amount, then by closest amount within a percentage tolerance.

    Arrays & Hashinghash-mapsimulationmatchingfloating-point
  • Arrays & HashingEasyAuto-graded
    Sliding Marble on a Tiltable Grid with Scheduled Tilts

    Simulate a marble on a grid whose tilt changes at scheduled times, and find its final cell efficiently when the end time can reach a billion seconds.

    Arrays & Hashingsimulationgridtime-segmentstwo-pointers
  • Arrays & HashingMediumAuto-graded
    Best Single Round-Trip Gain Across Tickers in an Unordered Log

    Find the largest gain from buying and later selling the same ticker on a strictly later date, given an unsorted log with duplicate dates; tests grouping, sorting and careful running-minimum updates.

    Arrays & Hashinghash-mapsortinggreedytime-series
  • Arrays & HashingEasyAuto-graded
    Count Repeated Strings in a Large List

    Tests hash-map frequency counting: find every string occurring more than once in a list and report its count, using exact comparison.

    Arrays & Hashinghash-mapcountingstringsfrequency
  • Trees & GraphsMediumAuto-graded
    Rebuild a Search Tree from Its Preorder Listing

    Rebuild a binary search tree from its preorder listing of distinct integers in linear time, then report it in level order with null placeholders. Tests stack-based construction and BFS serialization.

    Trees & Graphsbinary-search-treestackpreorderbfs
  • Data Structure DesignMediumAuto-graded
    Per-Tab Navigation Timeline Replay

    Simulate independent per-tab navigation timelines with a cursor, supporting visit, back and forward, and replay a batch of operations to collect their results.

    Data Structure Designdesignhash-mapsimulationcursor
  • Greedy & IntervalsMediumAuto-graded
    Daily Flat-Fee Cap on Overlapping Job Charges

    Sum per-day min(active cost, flat fee) over huge day ranges using an event sweep, with the result taken modulo 1,000,000,007.

    Greedy & Intervalsline-sweepintervalsdifference-arraymodular-arithmetic
  • Heaps, Sorting & SearchMediumAuto-graded
    Pick the Element at a Given Rank From the Top

    Find the k-th largest value in an unsorted integer list, counting duplicates separately, without necessarily sorting the whole list.

    Heaps, Sorting & Searchheapquickselectselectionarrays
  • Data Structure DesignHardAuto-graded
    Track Covered Spans Under Add, Erase and Check Commands

    Maintain a set of half-open real intervals under add, remove and fully-covered queries, merging touching spans and splitting spans on removal.

    Data Structure Designintervalsbinary-searchsimulationsorted-list
  • Trees & GraphsMediumAuto-graded
    Combine Config Trees and Parse a Canonical Encoding

    Merge two keyed n-ary trees by summing values, encode them canonically, and strictly parse an encoded string with validation.

    Trees & Graphstreerecursionparsingserialization
  • Arrays & HashingEasyAuto-graded
    Tally Tokens and Report the Three Most Common

    Count occurrences of each string in a list with a hash map, then rank by count with an alphabetical tie-break to extract the top three entries.

    Arrays & Hashinghash-mapcountingsortingtie-breaking
  • Math & Bit ManipulationMediumAuto-graded
    Gambler's Ruin: Success Probability and Duration Score

    Compute the chance a random walk hits a target before zero using a closed form, handling the fair case and overflow, and return a fixed duration formula.

    Math & Bit Manipulationprobabilitymarkov-chainclosed-formnumerical-stability
  • Dynamic ProgrammingMediumAuto-graded
    Best Haul from a Row of Stalls Without Adjacent Picks

    Pick values from a row so that no two chosen positions are neighbors, maximizing the total, which tests recognizing and implementing a simple one-dimensional dynamic programming recurrence.

    Dynamic Programmingdynamic-programmingarraysnon-adjacent-selection
  • Trees & GraphsMediumAuto-graded
    Smallest Job Schedule Under Dependency Rules

    Produce the lexicographically smallest topological ordering of a dependency graph, or an empty list if the dependencies contain a cycle.

    Trees & Graphstopological-sortgraphheapcycle-detection
  • Arrays & HashingMediumAuto-graded
    Users Needed Per Group for a Two-Proportion Test

    Compute the smallest equal group size for a two-sided two-proportion z-test, given a baseline rate, relative uplift, significance level and target power.

    Arrays & Hashingstatisticssample-sizepower-analysisab-testing
  • StringsMediumAuto-graded
    Longest Repeated-Letter Block With a Limited Rewrite Budget

    Find the longest block of identical letters obtainable by rewriting at most k characters, testing sliding-window reasoning on majority counts for strings up to 100,000 characters.

    Stringssliding-windowstringstwo-pointershashing
  • Arrays & HashingMediumAuto-graded
    Window Sums Within [k, 2k] for Power-of-Two Lengths

    Enumerate every subarray whose length is a power of two and whose sum falls in [k, 2k], using prefix sums to get an O(n log n) solution with ordered output.

    Arrays & Hashingprefix-sumsliding-windowsubarrayenumeration
  • Arrays & HashingMediumAuto-graded
    Deterministic Mini-Batch Gradient Descent for a Line Fit

    Fit a slope and intercept to 2D points by running deterministic mini-batch gradient descent on mean squared error, with exact batching, update order and edge-case rules.

    Arrays & Hashinggradient-descentlinear-regressionmini-batchoptimization
  • Greedy & IntervalsMediumAuto-graded
    Coalesce Touching Segments and Measure Coverage

    Merge half-open integer segments that overlap or touch end-to-start, then report the merged segments in order along with their combined covered length.

    Greedy & Intervalsintervalssortingsweepmerge
  • Arrays & HashingMediumAuto-graded
    Rank Among Values Occurring Once Across Two Lists

    Count occurrences across two combined lists, keep values seen exactly once, and return the k-th largest of them or -1 if there are fewer than k.

    Arrays & Hashinghash-mapcountingsortingheap
  • Trees & GraphsMediumAuto-graded
    Balance Path Totals in a Rooted Tree with Minimum Bumps

    Compute the fewest +1 increments that make every root-to-leaf path total equal in a large rooted tree given as a parent array, which needs a bottom-up greedy and an iterative traversal.

    Trees & Graphstreegreedybfstree-dp
  • Arrays & HashingMediumAuto-graded
    Fill a Padded Sorted Buffer from a Second Sorted List

    Merge two sorted lists into the first, which has trailing spare slots, without extra memory; tests back-to-front two-pointer merging.

    Arrays & Hashingtwo-pointersin-placesortingmerge
  • Data Structure DesignMediumAuto-graded
    Rolling Forklift Ping Counts with Late Arrivals and Shift Tracking

    Simulate a fleet telemetry service that tracks per-forklift pings in a global 15-minute window, handles late pings, and counts clocked-in forklifts.

    Data Structure Designsliding windowheaphash mapdata structure design
  • Arrays & HashingEasyAuto-graded
    Bump a Digit-Array Number Up by One

    Increment a large non-negative number stored as a digit list by one, handling carry propagation and length growth without converting to an integer.

    Arrays & Hashingarrayscarrysimulationmath
  • Data Structure DesignEasyAuto-graded
    Bidirectional Page Navigation with Integer Cursors

    Simulate a paginator that serves pages forward and backward from integer cursors, with correct clamping at both ends and for a short final page.

    Data Structure Designdesignpaginationsimulationarray-slicing
  • Stacks & QueuesMediumAuto-graded
    Validate Balanced Round, Square and Curly Brackets

    Decide whether a string of three bracket kinds is balanced, testing last-in-first-out matching with a stack and handling crossings and leftover or stray brackets.

    Stacks & Queuesstackstringsparsingbracket-matching
  • Data Structure DesignMediumAuto-graded
    Quota-Based Storage Service Simulator with Snapshots

    Simulate a command stream on a storage service with per-user quotas, ownership transfer, prefix-based top-n listing, and per-user snapshot and restore.

    Data Structure Designdesignhash-mapsimulationsorting
  • Math & Bit ManipulationEasyAuto-graded
    Dice Duel Wager: Expected Profit and Play Decision

    Compute the expected profit of a two-dice wager where ties favor the opponent, and decide whether a risk-neutral player should accept it.

    Math & Bit Manipulationprobabilityexpected-valuemathdice
  • Math & Bit ManipulationEasyAuto-graded
    Five Quick Probability Puzzles: Dice, Deck, Coins, Boxes

    Work out five small probability puzzles using symmetry, complements, counting and pigeonhole, and return the exact answers as fraction strings in order.

    Math & Bit Manipulationprobabilitycombinatoricspigeonholesymmetry
  • Trees & GraphsMediumAuto-graded
    Course Plan Builder with Already-Passed Classes

    Build a valid course order from prerequisite pairs while skipping passed courses, using a topological sort with a fixed tie-break order and cycle detection.

    Trees & Graphstopological-sortgraphbfscycle-detection