KatInterview

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

Coding Interview Problems

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

6029
Problems
2232
Auto-graded
15
Topics
273
Added today

Showing 1141–1170 of 2131 results

  • Data Structure DesignMediumAuto-graded
    Recency-Evicting Cache Simulator

    Simulate a fixed-capacity key-value store that evicts the least recently used entry, processing a batch of get and put commands in constant time each.

    Data Structure Designhash-mapdoubly-linked-listlru-cachesimulation
  • Math & Bit ManipulationMediumAuto-graded
    Correlation Bounds, Equicorrelated Triples, and Box-Muller Sampling

    Compute a feasible correlation interval, give coefficients for three equally anti-correlated variables, and convert uniform values to normals with the Box-Muller transform.

    Math & Bit Manipulationprobabilitycorrelationbox-mullersimulation
  • Greedy & IntervalsMediumAuto-graded
    Courier Earnings from Overlapping Order Timelines

    Sweep over unsorted accept/fulfill events to total a courier's earnings, where pay per minute scales with the number of simultaneously open orders.

    Greedy & Intervalssweep-linesortingintervalssimulation
  • Arrays & HashingMediumAuto-graded
    Target-Sum Windows and Largest Building Cluster

    Combine a prefix-sum hash map to count contiguous slices summing to a target with a grid flood fill to find the largest 4-connected cluster of buildings.

    Arrays & Hashingprefix-sumhash-mapflood-fillgrid
  • Arrays & HashingMediumAuto-graded
    Peak Pace Over Tightest 1000-Meter Windows in Interval Logs

    Sliding-window problem: for each end index find the shortest suffix with at least 1000 meters, compute its average speed, and return the maximum across all end indices.

    Arrays & Hashingsliding-windowtwo-pointersprefix-sumsarrays
  • Arrays & HashingEasyAuto-graded
    Roster Screening with Optional Age, Pay, and Job Limits

    Scan a list of employee records and keep those meeting every enabled optional range or membership rule, preserving order and leaving the input untouched.

    Arrays & Hashingfilteringhash-setoptional-parameterssimulation
  • Trees & GraphsMediumAuto-graded
    Live Archipelago Counter with Incremental Land Reclamation

    Count 4-connected land regions in a grid, then report the updated region count after each cell is converted from water to land, using incremental connectivity.

    Trees & Graphsunion-findgridconnected-componentsincremental-updates
  • Greedy & IntervalsMediumAuto-graded
    Booked Time and Peak Room Demand for a Schedule

    Compute the total time covered by a set of half-open intervals and the maximum number of simultaneously active intervals, ignoring empty or reversed ones.

    Greedy & Intervalsintervalssweep-linesortingmerge-intervals
  • Arrays & HashingMediumAuto-graded
    Batch Gradient Descent Linear Regression Session Simulator

    Simulate a fit/predict command sequence for a linear model trained with batch gradient descent on mean squared error, using plain Python lists.

    Arrays & Hashinggradient-descentlinear-regressionmsesimulation
  • Heaps, Sorting & SearchMediumAuto-graded
    Cheapest Full Merge and Matching-Sum Product Total

    Combine a Huffman-style min-heap greedy for the cheapest full merge with a frequency-map count of index pairs hitting a target sum, summing their products.

    Heaps, Sorting & Searchheapgreedyhash-mapcounting
  • Data Structure DesignMediumAuto-graded
    Lifespan Lookups for Orders and Order Groups in a Replay Log

    Simulate a class through an operations list, tracking per-order and per-group start and end times so lookups run in constant time, with groups reporting 0 while any member is open.

    Data Structure Designhash-mapdesignsimulationaggregation
  • StringsEasyAuto-graded
    Tab-Scoped Ticket Search with Case-Insensitive Matching

    Filter support tickets by tab, then by a case-insensitive substring match on title or assignee, handling blank queries and unassigned tickets.

    Stringsstringsfilteringcase-insensitivesimulation
  • Arrays & HashingMediumAuto-graded
    Remainder-Sum Windows and Bracket Cleanup

    Count contiguous subarrays whose sum has a given remainder using prefix-sum remainders, and delete the fewest parentheses to balance a string in a fixed, deterministic way.

    Arrays & Hashingprefix-summodular-arithmetichash-countinggreedy
  • Heaps, Sorting & SearchMediumAuto-graded
    One-Car Sweep Scheduler: Order the Elevator Stops

    Order a single elevator's pending floor requests using a one-reversal sweep policy with a priority queue, merging duplicates and respecting the starting direction.

    Heaps, Sorting & Searchheappriority-queuesortingsimulation
  • Trees & GraphsMediumAuto-graded
    Cheapest Letter Rewrites with Directed Price Rules

    Compute the minimum cost to rewrite one string into another with directed priced letter swaps, using shortest paths over 26 letters and handling impossible positions and large totals.

    Trees & Graphsgraphfloyd-warshallshortest-pathstrings
  • Data Structure DesignMediumAuto-graded
    Duplicate Log Suppression Within a Cooldown Window

    Simulate a duplicate-log filter driven by an operation script, tracking per-message cooldowns where only accepted messages restart the timer.

    Data Structure Designhash-mapdesignsimulationrate-limiting
  • Trees & GraphsMediumAuto-graded
    Fewest-Hop Route Through Flaky Page Fetches

    Run BFS on a link graph to find the lexicographically smallest fewest-hop route, where some pages fail a set number of times before their links load.

    Trees & Graphsbfsgraphshortest-pathretries
  • Trees & GraphsMediumAuto-graded
    Rainbow Walks of Length Three in a Typed Graph

    Count ordered 4-vertex walks along edges in an undirected graph whose vertices carry one of four labels, where each walk uses every label exactly once.

    Trees & Graphsgraphcountingcombinatoricsadjacency-list
  • Math & Bit ManipulationEasyAuto-graded
    Eventual Winner Odds in a Draw-Two Card Duel with Replays

    Compute the probability that the first of two drawers eventually wins a rank-comparison game with replayed ties, using counting and a symmetry argument.

    Math & Bit Manipulationprobabilitysymmetrycountingmath
  • Data Structure DesignMediumAuto-graded
    Slide a Block in a Grid and Filter Repeated Log Calls

    Move a rectangular block inside a 2D grid without corrupting overlapping data, then run a sliding-window duplicate filter over a list of timestamps.

    Data Structure Designmatrixin-placesliding-windowdeque
  • Trees & GraphsMediumAuto-graded
    Earliest Finish Time for a Dependent Task Pipeline

    Find the minimum time to complete all tasks with durations and prerequisites under unlimited parallelism, or detect a circular dependency, using longest path in a DAG with topological ordering.

    Trees & Graphstopological-sortgraphdaglongest-path
  • Heaps, Sorting & SearchMediumAuto-graded
    First Index at Least Target in a Padded Sorted Stream

    Find the first index with value at least the target in a sorted sequence of hidden length, using doubling probes followed by binary search.

    Heaps, Sorting & Searchbinary-searchexponential-searchsorted-arrayinvariants
  • Trees & GraphsMediumAuto-graded
    Flip Pipes to Flow Outward From a Source Station

    Count the directed edges of a tree that point toward a chosen root, which is the minimum number of flips needed to orient every edge away from it.

    Trees & Graphstreegraph-traversaldfsbfs
  • Trees & GraphsMediumAuto-graded
    Grid Contagion with Neighbor-Count Thresholds

    Compute when each grid cell becomes infected under a synchronous neighbor-count rule, using a multi-source BFS that updates counts incrementally instead of rescanning each round.

    Trees & Graphsbfsgridsimulationmulti-source-bfs
  • Heaps, Sorting & SearchMediumAuto-graded
    Expiring Compute Credits: Offline Ledger Replay

    Replay a shuffled log of credit grants, spends and balance queries in time order, spending the soonest-expiring credits first, using a heap and sorting.

    Heaps, Sorting & Searchheapsortingsimulationoffline-processing
  • Trees & GraphsMediumAuto-graded
    Leftmost and Rightmost Nodes per Depth from a Serialized Tree

    Given a level-order serialized binary tree, return the first and last node value at each depth, testing BFS over an array-encoded tree and careful handling of null slots.

    Trees & Graphsbinary-treebfslevel-orderserialization
  • Heaps, Sorting & SearchMediumAuto-graded
    Median Tracker for an Incoming Number Feed

    Maintain the median of a growing sequence after each new value arrives, testing efficient order-statistic upkeep with a pair of heaps.

    Heaps, Sorting & Searchheaptwo-heapsstreamingmedian
  • Trees & GraphsMediumAuto-graded
    Longest Path Between Any Two Nodes in an Indexed Binary Tree

    Find the longest path, counted in edges, between any two nodes of a binary tree stored as a child-index list, testing tree height computation and avoiding deep recursion.

    Trees & Graphsbinary-treedfsbfstree-height
  • Greedy & IntervalsMediumAuto-graded
    Pick One Day Per Workshop Within Its Availability Window

    Choose a distinct day for as many workshops as possible, each within its own window, using an earliest-deadline-first greedy with a min-heap.

    Greedy & Intervalsgreedyheapintervalssorting
  • Linked ListsMediumAuto-graded
    Clone a Linked Chain with Arbitrary Jump Links

    Build a singly linked list with extra jump pointers from index arrays, deep-copy it without sharing nodes, and report the copy's structure by index.

    Linked Listslinked-listhash-mapdeep-copypointers