KatInterview

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

Coding Interview Problems

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

6043
Problems
2238
Auto-graded
15
Topics
274
Added today

Showing 1261–1290 of 2791 results

  • Data Structure DesignMediumModel answer
    Design a Weighted Sampling Generator with Dynamic Updates

    Implement a class for weighted sampling that supports O(1) sampling for static inputs and logarithmic updates for dynamic environments.

    Data Structure Designdesign-dsheaps-sortingmath-bits
  • Arrays & HashingMediumAuto-graded
    Price Card Payments with Tiered Rates and Running Merchant Totals

    Parse comma-separated payment rows, build a per-row rate from several rules plus a per-merchant running total, and round fees exactly to whole cents.

    Arrays & Hashinghash-mapparsingsimulationrounding
  • Math & Bit ManipulationMediumAuto-graded
    Delta-Method Variance of a Ratio of Two Sample Means

    Apply a first-order Taylor expansion to get the approximate variance of a ratio of two correlated sample means, including the covariance term.

    Math & Bit Manipulationdelta-methodvariancecovarianceratio-metrics
  • Math & Bit ManipulationMediumAuto-graded
    Gap in Days Between Two Calendar Strings Without Date Libraries

    Parse two ISO-style date strings and compute the absolute day gap using manual Gregorian leap-year logic, without any date or calendar library.

    Math & Bit Manipulationdate-arithmeticleap-yearstring-parsingmath
  • Arrays & HashingMediumAuto-graded
    Find Accounts With Five Distinct Contacts in a Week

    Sliding-window distinct counting per group: find callers who reach at least five different receivers within any 7-day span of their call log.

    Arrays & Hashingsliding-windowhash-mapgroupingtimestamps
  • Data Structure DesignMediumAuto-graded
    Work Queue Tracker with Owners, Closing, and Late Lookups

    Simulate a task tracker driven by a list of operations, handling creation, reassignment, completion, and multi-key sorted queries while returning one result per operation.

    Data Structure Designdesignhash-mapsortingsimulation
  • Trees & GraphsMediumAuto-graded
    Column-by-Column Readout of a Level-Order Encoded Tree

    Compute the column-wise readout of a binary tree given as a level-order array, ordering nodes by column, then row, then value.

    Trees & Graphsbinary-treebfshash-mapsorting
  • Heaps, Sorting & SearchMediumAuto-graded
    Valley Finder: Binary Search on an Unsorted Zigzag Array

    Find a valley index in an array of adjacent-distinct integers in logarithmic time, using a fixed halving rule that makes the returned index deterministic.

    Heaps, Sorting & Searchbinary-searcharraysinvariantsiterative
  • Data Structure DesignMediumModel answer
    Cross-Venue Quote Book and Arbitrage Scanner

    Build an in-memory engine that keeps the latest valid top-of-book quote per venue, expires old ones, and reports the most profitable buy-low/sell-high pair across venues.

    Data Structure Designclass-designhash-mapmarket-dataedge-cases
  • Dynamic ProgrammingMediumAuto-graded
    Tallest Staircase Walk Across a Number Board

    Find the longest chain of orthogonally adjacent cells with strictly increasing values in a 2D grid, testing DAG longest-path DP, memoization, and avoiding deep recursion.

    Dynamic Programmingdynamic-programminggraphdfsmemoization
  • StringsMediumAuto-graded
    Left-to-Right Calculator Using Only Scalar State

    Evaluate a no-parentheses arithmetic string with correct precedence and truncating division in one pass, using only a few scalar variables instead of a stack.

    Stringsstring-parsingtwo-pointerssimulationconstant-space
  • Arrays & HashingMediumAuto-graded
    Audit Purchase Events Against a Payment Ledger

    Aggregate daily purchase metrics from event logs and reconcile two event snapshots against a ledger to judge whether a tracking fix worked, using hash-map grouping.

    Arrays & Hashinghashingaggregationreconciliationdictionaries
  • Data Structure DesignMediumAuto-graded
    Per-Key Cooldown Filter for a Timestamped Event Feed

    Walk a time-ordered event feed and decide which events pass a 10-second per-key cooldown, where only accepted events restart the cooldown.

    Data Structure Designhash-mapsimulationrate-limitingstreams
  • Arrays & HashingMediumModel answer
    Simulate Grid Rover Fleet Collision Logic

    Simulate the concurrent step-by-step navigation of multiple automated grid rovers, handling collisions, static obstacles, and grid bounds.

    Arrays & Hashingarrayssimulationmatrixhash-table
  • Arrays & HashingEasyAuto-graded
    Most Frequently Booked Vehicle

    Count how many booking records each vehicle has and return the ID with the highest count, breaking ties by the smallest ID.

    Arrays & Hashinghash-mapcountingtie-breaking
  • Arrays & HashingMediumAuto-graded
    Inner Product of Two Index-Value Lists

    Compute the inner product of two sparse vectors given as sorted index-value pairs by intersecting their indices with a linear merge, without building dense arrays.

    Arrays & Hashingtwo-pointerssparse-vectorsorted-mergesimulation
  • Data Structure DesignMediumModel answer
    Thread-Safe Ledger Accounts with Transfer and Absorb Operations

    Design a concurrency-safe Account class supporting deposits, withdrawals, atomic transfers, and absorbing another account, while preventing overdrafts, deadlocks, and operations on closed accounts.

    Data Structure Designoopconcurrencylockingdeadlock
  • Math & Bit ManipulationEasyModel answer
    Axial Tilt and Doubling Money: Two Estimation Questions

    Explain the physical cause of hot summers and cold winters, then compute the balance of a $1,000 deposit that earns 100% interest compounded yearly for 20 years.

    Math & Bit Manipulationestimationcompound-interestexponential-growthmental-math
  • Data Structure DesignMediumModel answer
    Object-Oriented Design for a Multi-Floor Garage Allocator

    Design classes and an allocation API for a multi-floor garage that assigns the closest suitable bay to each vehicle, stays correct under concurrent requests, and handles a full garage.

    Data Structure Designobject-oriented-designconcurrencyheaplow-level-design
  • Greedy & IntervalsMediumAuto-graded
    Earliest Shared Free Slot Across Several Schedules

    Find the earliest meeting slot of a given length that fits inside everyone's availability window and avoids every busy block, by intersecting windows and merging busy intervals.

    Greedy & Intervalsintervalssweep-linesortingscheduling
  • Greedy & IntervalsMediumAuto-graded
    Merge Event Windows Within Each Locality

    Join two record lists by id, group event time ranges by locality, merge overlapping or touching ranges, and return the merged windows in a specified sort order.

    Greedy & Intervalsintervalsmerge-intervalshash-mapsorting
  • Math & Bit ManipulationHardAuto-graded
    Streaming Run/Bit-Pack Codec Session Simulator

    Simulate a codec session that buffers int32 values, emits run-length and bit-packed blocks on flush, and decodes block lists back to integers.

    Math & Bit Manipulationbit-manipulationcompressionsimulationtwos-complement
  • Data Structure DesignMediumAuto-graded
    Funding Ledger with Rail-Specific Settlement and Window Caps

    Simulate an ordered account ledger where each payment rail has its own settlement delay, cutoff-shifted window assignment, and per-window cap, and output the combined results.

    Data Structure Designsimulationhash-mapheapdesign
  • Data Structure DesignMediumModel answer
    Build a Three-Stage Signup Wizard with React Reducer State

    Design a React wizard with profile, address and review stages, covering validation, guarded navigation, disabled controls, a submit spinner and server error display, plus scaling and performance trade-offs.

    Data Structure DesignreactformsuseReducervalidation
  • Arrays & HashingMediumModel answer
    Simulate Cascade Board Game Outcome

    Simulate a custom board game involving stack placing and directed toppling moves to determine the game outcome.

    Arrays & Hashingarrayssimulationmatrix
  • Dynamic ProgrammingHardAuto-graded
    Minimum Disorder When Interleaving Two Job Queues

    Interleave two letter strings while keeping each one's order, minimizing out-of-order pairs; tests 2D prefix DP with O(1) transition costs from alphabet-count tables.

    Dynamic Programmingdynamic-programmingstringsprefix-countsinterleaving
  • Arrays & HashingEasyAuto-graded
    Score a Top-k Search Result Against Labeled Files

    Clean a noisy ranked result list (missing, duplicated, unknown, or oversized) and compute precision and recall against ground-truth labels.

    Arrays & Hashinghashingsetsmetricsinput-validation
  • Math & Bit ManipulationEasyAuto-graded
    Detect a Rate Reversal Between Strata and Pooled Totals

    Compare two groups' success rates per stratum and pooled, using exact integer cross-multiplication, to detect when a consistent stratum winner flips in the aggregate.

    Math & Bit Manipulationsimulationfractionsaggregationsimpsons-paradox
  • StringsMediumAuto-graded
    Fewest Leading Digits Needed to Rearrange Into Each Word

    For each query digit string, find the shortest prefix of a digit string containing enough of each digit to form it, using per-digit occurrence lists and a max over digits.

    Stringsstringshashingcountingprecomputation
  • Trees & GraphsMediumAuto-graded
    Audit a Workflow Run Against Dependencies and Precedence Rules

    Check a run order against a task dependency graph, mandatory tasks and extra precedence pairs, while rejecting duplicates, unknown tasks and cyclic constraints.

    Trees & Graphsgraphtopological-sortcycle-detectionhash-map