KatInterview

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

Coding Interview Problems

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

6033
Problems
2234
Auto-graded
15
Topics
274
Added today

Showing 1111–1140 of 2133 results

  • Heaps, Sorting & SearchHardAuto-graded
    Pick the Bottle Kit With the Least Leftover Volume

    Choose the bottle kit that serves every dose request with minimal total leftover space, using sorting, prefix sums and binary search to stay efficient on large inputs.

    Heaps, Sorting & Searchbinary-searchprefix-sumssortinggreedy
  • Math & Bit ManipulationMediumAuto-graded
    Matrix Product, Fast Power and Fibonacci Toolkit

    Combine matrix multiplication, square-and-multiply exponentiation and 2x2 matrix-power Fibonacci, with optional modular arithmetic, in one function.

    Math & Bit Manipulationmatrix-multiplicationfast-exponentiationfibonaccimodular-arithmetic
  • Data Structure DesignMediumAuto-graded
    Most Likely Follower Lookup via Operation Log

    Simulate a bigram next-word model from an operation log, returning the most frequent follower with lexicographic tie-breaking and an empty string when none exists.

    Data Structure Designhash-mapdesigncountingsimulation
  • Arrays & HashingMediumAuto-graded
    Column-wise Gap Filling with Mean, Median or Mode

    Fill None cells in a table column by column with the mean, median or smallest-most-frequent value of the observed entries, without mutating the input.

    Arrays & Hashingarrayssimulationstatisticsdata-cleaning
  • StringsMediumAuto-graded
    Longest Repeat-Free Concatenation, Lexicographically Smallest

    Pick words and order them to form the longest string with no repeated character, breaking ties by smallest lexicographic order; tests subset backtracking with disjoint-set pruning.

    Stringsbacktrackingsubsetsstringsbitmask
  • Trees & GraphsMediumAuto-graded
    Uncover Cells on a Minefield Grid with Flood Expansion

    Apply a Minesweeper-style tap to a grid, expanding through zero-mine regions with breadth-first search and labeling cells with adjacent mine counts.

    Trees & Graphsbfsgridmatrixsimulation
  • Data Structure DesignMediumAuto-graded
    Restaurant Queue Tracker with Fast Rank Lookup

    Replay a list of queue operations on a first-come waitlist, supporting add, remove-by-id, rank lookup and front peek, with rank queries faster than a linear scan.

    Data Structure Designdesignorder-statistictreaphash-map
  • Trees & GraphsMediumAuto-graded
    Grid Distance to the Closest Marked Cell

    Compute, for every cell of a grid, the fewest orthogonal steps to the closest marked cell, using a single multi-source breadth-first search; -1 everywhere when no cell is marked.

    Trees & Graphsbfsmulti-source-bfsgridshortest-path
  • Math & Bit ManipulationHardAuto-graded
    Ordered IPv4 Access List: Verdict for an Address or Entire Subnet

    Evaluate an ordered first-match IPv4 access list for a single address or a whole CIDR block, which needs prefix arithmetic and interval reasoning rather than enumerating addresses.

    Math & Bit Manipulationcidrbit-manipulationstacksorting
  • Trees & GraphsMediumAuto-graded
    Chained Exchange Rates: Resolve Conversion Queries

    Build a bidirectional weighted graph from exchange rates and answer conversion queries with a deterministic BFS that multiplies rates along the first-found path, or -1.0 if none exists.

    Trees & Graphsgraphbfsweighted-graphhash-map
  • Math & Bit ManipulationEasyAuto-graded
    Expected Draws Until a Second Distinct Token Shows Up

    Compute, as a floating-point number, the expected number of draws from a fixed three-outcome distribution until two different outcomes have appeared, using conditioning and geometric waiting times.

    Math & Bit Manipulationprobabilityexpected-valuegeometric-distributionmath
  • Arrays & HashingHardAuto-graded
    Complete a Partially Filled Number Grid with Row, Column, Box Rules

    Fill in the blanks of a 9x9 digit grid so every row, column and 3x3 block holds each digit 1-9 once, testing backtracking with constraint pruning.

    Arrays & Hashingbacktrackingconstraint-satisfactionbitmaskrecursion
  • Arrays & HashingMediumAuto-graded
    Rainwater Held Between Terrain Columns

    Compute total rainwater stored between unit-width columns of given heights, aiming for a single pass with constant extra memory using the two-pointer technique.

    Arrays & Hashingtwo-pointersarraysgreedy
  • Dynamic ProgrammingMediumAuto-graded
    Cheapest Right-Down Route Through a Cost Grid

    Compute the minimum total cost of a route from the top-left to the bottom-right of a grid when only right and down moves are allowed, using dynamic programming.

    Dynamic Programmingdynamic-programminggridmatrixoptimization
  • Heaps, Sorting & SearchMediumAuto-graded
    Rank Anti-Diagonal Strings of a Letter Grid

    Build a string for each anti-diagonal of a letter grid, read bottom-left to top-right, and return diagonal indices ordered by string, with ties broken by index.

    Heaps, Sorting & Searchmatrixsortingstringstie-breaking
  • Trees & GraphsMediumAuto-graded
    Is the Target's Cell Forced by Every Valid Seating?

    Backtracking over placements of named items on a grid under pairwise relative-position clues, deciding whether the target ends up in one cell across all valid layouts.

    Trees & Graphsbacktrackingconstraint-satisfactiongridsearch
  • Arrays & HashingEasyAuto-graded
    Locate Two Entries That Add Up to a Goal

    Find the two distinct positions in an integer list whose values sum to a goal, using a single-pass hash map lookup instead of checking every pair.

    Arrays & Hashinghash-maparrayscomplement-lookup
  • Data Structure DesignMediumAuto-graded
    Multiset Frequency Log with Lazy Snapshot Pool Top-K

    Simulate insert, remove and top-k queries on a multiset using a snapshot pool whose stale entries are discarded lazily, testing hash maps with heaps and exact rule-following.

    Data Structure Designhash-mapheaplazy-deletiondesign
  • Trees & GraphsHardAuto-graded
    Semester Planner Plus Burst-Limited Request Filter

    Combine topological ordering to find the minimum number of semesters (or detect a cycle) with a deque-based simulation of a two-rule request throttle that reports dropped timestamps.

    Trees & Graphstopological-sortgraphcycle-detectionsliding-window
  • StringsMediumAuto-graded
    Locate the First Occurrence of a Needle in a Haystack

    Find the earliest starting index of a pattern inside a text in linear time, handling empty inputs and repetitive patterns, using a prefix-function (KMP-style) scan.

    Stringsstringskmptwo-pointerspattern-matching
  • Greedy & IntervalsMediumAuto-graded
    Peak Concurrent Shifts Across Half-Open Time Ranges

    Find the largest number of half-open time ranges that overlap at one instant, handling shared endpoints, empty ranges and large inputs with a sweep over sorted boundaries.

    Greedy & Intervalssweep-lineintervalssortinghash-map
  • StringsEasyAuto-graded
    Tally Clean Tokens in a Space-Delimited Line

    Split a line on spaces and count the tokens made only of ASCII letters and the marks , . ? !, testing exact tokenization and character-class checks.

    Stringsstringsparsingtokenizationhash-set
  • Arrays & HashingEasyAuto-graded
    Experiment Sizing and Beta Posterior Update

    Compute the per-group sample size for a two-proportion test from a given formula, and update a Beta prior with observed Bernoulli outcomes.

    Arrays & Hashingstatisticspower-analysisbayesian-updatebeta-binomial
  • Data Structure DesignMediumAuto-graded
    Closest Repeat Distance with Fast Threshold Queries

    Precompute the smallest distance between equal values in an array once, then answer many "repeat within k" and "closest repeat" queries in constant time each.

    Data Structure Designhash-mappreprocessingbatch-queriesarrays
  • Math & Bit ManipulationEasyAuto-graded
    Equal-Sized Uniform Piles From a Card Collection

    Decide whether a multiset of integers can be split into uniform piles that all share one common size of at least two, testing counting and the GCD insight.

    Math & Bit Manipulationgcdhash-mapcountingnumber-theory
  • Arrays & HashingEasyAuto-graded
    Top Five Senders and Receivers From Signed Transfer Logs

    Count senders and receivers from signed transfer records in a single pass, then pick the five most frequent on each side with a deterministic tie-break.

    Arrays & Hashinghash-mapcountingheapstreaming
  • Data Structure DesignMediumAuto-graded
    Simulate a Four-Seat Trick-Taking Card Game with Scoring

    Simulate a full 13-trick, four-player card game with deterministic dealing, follow-suit rules, and point scoring, and return the complete game record.

    Data Structure Designsimulationstate-managementsortinghash-map
  • Data Structure DesignMediumAuto-graded
    Count-Feature Text Classifier via Command Replay

    Simulate a stateful multinomial Naive Bayes model driven by fit and predict commands, using smoothed log-probabilities and a deterministic tie-break.

    Data Structure Designnaive-bayessimulationlog-probabilitiessmoothing
  • Math & Bit ManipulationEasyAuto-graded
    Mean of a Numeric List with Empty-Input Fallback

    Compute the arithmetic mean of a list of numbers, returning 0 for an empty list, testing basic edge-case handling and complexity reasoning.

    Math & Bit Manipulationarraysmathedge-cases
  • Arrays & HashingMediumAuto-graded
    Interleave Signs With Stable Order and Trailing Zeros

    Build a new list that alternates positives and negatives (starting positive), keeps same-sign order, appends leftover elements, and places zeros last.

    Arrays & Hashingarraystwo-pointersstable-partitionsimulation