KatInterview

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

Coding Interview Problems

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

6013
Problems
2228
Auto-graded
15
Topics
275
Added today

Showing 751–780 of 2781 results

  • Trees & GraphsMediumAuto-graded
    Players Whose Leaderboard Position Is Forced

    Find every player comparable to all others in a consistent win/loss DAG, using transitive reachability in both directions, ideally with bitsets.

    Trees & Graphsgraphtopological-sorttransitive-closurebitset
  • Math & Bit ManipulationEasyAuto-graded
    Product of Three Dice: Summary Statistics Report

    Enumerate all 216 outcomes of three dice to compute the mean, modes, prime probability and median of their product, and return a fixed risk note.

    Math & Bit Manipulationenumerationprobabilitycountingstatistics
  • Heaps, Sorting & SearchMediumModel answer
    Quicksort vs Mergesort: Hardware, Stability and Disk Trade-offs

    Compare two O(n log n) sorts by how they use caches, preserve tie order, resist bad inputs, and behave when data lives on disk instead of in memory.

    Heaps, Sorting & Searchquicksortmergesortstabilitycache-locality
  • Arrays & HashingEasyAuto-graded
    Find Lowest Cost Ticket Pair Across Consecutive Days

    Find the minimum combined cost of an outbound and return ticket where return happens strictly after departure.

    Arrays & Hashingarraysgreedyprefix-minimum
  • Arrays & HashingMediumAuto-graded
    Users Active for a Week Straight: Detect 7-Day Streaks in Event Logs

    Find users whose event log contains at least seven consecutive UTC calendar days of activity, using per-user day deduplication and a sorted streak scan.

    Arrays & Hashinghashingdatesstreakssorting
  • Dynamic ProgrammingEasyAuto-graded
    Bankrupt Risk in Dice Game

    Compute the exact probability of wealth hitting zero or below at any step during a finite sequence of random dice rolls.

    Dynamic Programmingdynamic-programmingmath-bitsstatistics
  • Arrays & HashingEasyAuto-graded
    Calculate Maximum Single-Trade Return

    Find the maximum non-negative profit from purchasing an asset on one day and selling it on a subsequent day.

    Arrays & Hashingarraysdynamic-programminggreedy-intervals
  • Math & Bit ManipulationEasyAuto-graded
    Middle Age Band Share Among Cycling Respondents

    Restrict a 3x3 survey table to one column and return an exact reduced fraction for a conditional probability.

    Math & Bit Manipulationprobabilityfractionstablesgcd
  • Data Structure DesignMediumAuto-graded
    Failure Streaks and Fix Times from a Live Test Log

    Process a stream of pass/fail log operations, answering shortest-fix-time and longest-concurrent-failure-window queries with an incremental, level-based data structure.

    Data Structure Designdesignstreamingintervalshash-map
  • Heaps, Sorting & SearchMediumAuto-graded
    K-th Smallest Entry in a Row and Column Sorted Grid

    Find the k-th smallest value in a two-dimensional grid where every row and column is sorted in ascending order.

    Heaps, Sorting & Searchbinary-searchmatrixheaps-sorting
  • Greedy & IntervalsMediumAuto-graded
    Largest Number With Even Counts of Both Digits

    Delete characters from a string of 1s and 2s so both digit counts are even and the number is largest, testing greedy deletion with parity reasoning.

    Greedy & Intervalsgreedystringstacksubsequence
  • Data Structure DesignMediumAuto-graded
    Replay Operations on a Fixed-Size Ring Buffer Queue

    Simulate a fixed-capacity circular FIFO queue from an operation log, handling wraparound, full and empty states, and logical index lookups in constant time per operation.

    Data Structure Designcircular-queuering-buffersimulationdesign
  • Data Structure DesignMediumModel answer
    Slot Availability Queries on a Sparse Number Line

    Handle an online stream of point-blocking and window-clearance queries on a huge integer line, and return a bit string with one result per query.

    Data Structure Designbinary-searchsorted-structuresfenwick-treecoordinate-compression
  • Arrays & HashingEasyAuto-graded
    Cross-Tabulate Records by Composite Row and Column Keys

    Group records by composite row and column keys, sum a value field per pair, and return the axes in first-seen order with a dense grid that has zeros for missing pairs.

    Arrays & Hashinghash-mapgroupingaggregationtuples
  • Stacks & QueuesMediumModel answer
    Build a Stack-Based Mini Language Interpreter in Python

    Write an interpreter that parses a line-based program of LOAD, STORE and integer arithmetic instructions, runs it on an operand stack, and returns the final variable memory.

    Stacks & Queuesinterpreterstackparsingerror-handling
  • Data Structure DesignHardAuto-graded
    Simulate LFU Cache Sequence

    Process a series of LFU cache queries with LRU tie-breaking and track the output of each operation.

    Data Structure Designhash-tablelinked-listdesignlfu-cache
  • Arrays & HashingMediumAuto-graded
    Gravity Grid: Pushing Tokens Up from Below and Spotting Matching Lines

    Simulate a grid where tokens are pushed in from the bottom of a column, and after each push report success and whether any full column or full row is single-typed.

    Arrays & Hashingsimulationmatrixstate-trackinggrid
  • Heaps, Sorting & SearchMediumModel answer
    Two-Sided Order Book Matching with Unit Orders

    Simulate a simple exchange: buys and sells of size one arrive in sequence, cross against the best resting price, and you return the total value of all executed trades.

    Heaps, Sorting & Searchheappriority-queuesimulationorder-book
  • Dynamic ProgrammingMediumAuto-graded
    Cheapest Daily Ticket Plan Without Back-to-Back Repeats

    Choose one of three item types each day with no type repeated on adjacent days, minimizing total cost and returning the unique optimal sequence of choices.

    Dynamic Programmingdynamic-programmingpath-reconstructionpaint-house
  • Math & Bit ManipulationMediumAuto-graded
    Overflow-Safe Probability Normalization of Raw Scores

    Convert a list of real scores into a probability distribution via exponentiation and normalization, without overflow or division-by-zero for extreme input values.

    Math & Bit Manipulationnumerical-stabilitymathfloating-pointarrays
  • Trees & GraphsMediumAuto-graded
    Smallest Valid Task Schedule with Prerequisites

    Produce the lexicographically smallest topological ordering of a directed graph, or report that no ordering exists because of a cycle.

    Trees & Graphstopological-sortheapgraphcycle-detection
  • Math & Bit ManipulationEasyAuto-graded
    Recover Total Weight From All Pairwise Crate Readings

    Tests the double-counting insight that each item appears in a fixed number of pair sums, so the total equals the sum of the readings divided by a constant.

    Math & Bit Manipulationmathcountingpairwise-sumsarithmetic
  • Math & Bit ManipulationEasyAuto-graded
    Chance a Pair Tops Another Pair in Four Random Ratings

    Compute the probability that two items from one group both beat two items from another group when all four scores are i.i.d. and continuous, using a symmetry and ranking-count argument.

    Math & Bit Manipulationprobabilitycombinatoricssymmetrybrainteaser
  • Trees & GraphsMediumAuto-graded
    Tree Height and Peak Concurrent Bookings

    Compute the height of an index-encoded binary tree without deep recursion, and the minimum rooms needed for half-open time intervals, returned together as a pair.

    Trees & Graphsbinary-treeiterative-dfsintervalssweep-line
  • Math & Bit ManipulationEasyAuto-graded
    Tally Repeat-Free Three-Digit Numbers Up To a Limit

    Count integers from 100 up to a given limit whose three digits are all different, using direct enumeration or combinatorial reasoning.

    Math & Bit Manipulationmathenumerationdigitscounting
  • StringsHardAuto-graded
    Build a Recursive-Descent Decoder for a JSON Subset

    Write a strict recursive-descent parser that turns JSON text into Python values and raises ValueError on any malformed input.

    Stringsparsingrecursive-descentstringsrecursion
  • Data Structure DesignMediumModel answer
    Build an In-Memory File Store with Quotas and Backups

    Implement an in-memory file store with prefix top-N queries, per-user quotas, user merging, and per-user backup and restore that never disturb other users.

    Data Structure Designdata-structure-designhash-mapheapin-memory-storage
  • Math & Bit ManipulationMediumAuto-graded
    Earliest Disc Overlap Among Unicycle-Driven Agents

    Simulate several disc-shaped agents with forward Euler unicycle motion and report the first time step at which any pair overlaps, with all pairs at that step.

    Math & Bit Manipulationsimulationgeometryfloating-pointpairs
  • Heaps, Sorting & SearchMediumAuto-graded
    Longest Uniform Cut Length from Rope Pieces

    Find the largest integer length such that cutting every rope into pieces of that length yields at least k pieces; tests binary search over a monotonic answer space.

    Heaps, Sorting & Searchbinary-searchbinary-search-on-answermonotonic-predicatearrays
  • Data Structure DesignMediumModel answer
    Reversible Wallet Balance Tracker with Undo and Redo

    Design an in-memory wallet class that applies relative changes and absolute resets to an integer-cent balance, with full undo and redo and constant-time operations.

    Data Structure Designdesignundo-redostackscommand-pattern