KatInterview

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

Coding Interview Problems

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

5969
Problems
2211
Auto-graded
15
Topics
273
Added today

Showing 31–60 of 2111 results

  • Stacks & QueuesEasyAuto-graded
    Typed Value Stack Interpreter with Mixed Addition

    Simulate a stack machine whose values are tagged ints or strings, where ADD sums two ints or concatenates otherwise, and return the printed lines.

    Stacks & Queuesstacksimulationstringstagged-union
  • Trees & GraphsMediumAuto-graded
    Minimum Hops Between Two Tasks in a Dependency Graph

    Find the fewest directed edges from a start node to a goal node in an acyclic graph, returning 0 for identical nodes and -1 when unreachable; tests BFS on unit-weight graphs.

    Trees & Graphsgraphbfsshortest-pathdag
  • Data Structure DesignEasyAuto-graded
    Simulate Driver Availability and Task Allocation

    Simulate driver registration and dispatch operations using standard queue processing and state tracking.

    Data Structure Designdata-structuresqueueshash-tablesimulation
  • Stacks & QueuesMediumAuto-graded
    Fixed-Width Window Folds with Add, Multiply, or AND

    Compute the fold of every length-k window of an array under a named associative operation, ideally in linear time without relying on inverse operations.

    Stacks & Queuessliding-windowtwo-stacksassociative-operationqueue
  • Data Structure DesignMediumAuto-graded
    Compute Compressed Vector Inner Product

    Process dynamic creation of compressed vectors and compute inner products using sparse representations.

    Data Structure Designarraysdesign-dshash-table
  • Greedy & IntervalsEasyAuto-graded
    Select Best Single Task Type

    Determine the task type index that maximizes total revenue within a given time budget using floor division and custom tie-breaking rules.

    Greedy & Intervalsgreedyarraysmath
  • Math & Bit ManipulationEasyAuto-graded
    Circle Pair Relationship Labeler

    Label each pair of circles by their geometric relationship using exact integer squared-distance comparisons and a strict rule order, including degenerate radius-zero cases.

    Math & Bit Manipulationgeometryinteger-arithmeticcase-analysissimulation
  • Data Structure DesignMediumAuto-graded
    Design a Recency-Tracking Key-Value Store

    Simulate operations on a custom key-value map that efficiently queries the most recently updated active entry.

    Data Structure Designdesign-dslinked-listsarrays
  • Arrays & HashingMediumAuto-graded
    Per-Move Win Tracker for a Square Noughts-and-Crosses Grid

    Replay a sequence of marks on an n-by-n grid and report after each one whether the mover has completed a row, column or diagonal, using per-line counters.

    Arrays & Hashingsimulationcountingmatrixdiagonals
  • Trees & GraphsMediumAuto-graded
    Collect Allowed Values Depth by Depth from a Nested-List Tree

    Traverse a binary tree given as nested lists level by level and keep only values from an allowed set, preserving left-to-right order and empty levels.

    Trees & Graphsbinary-treelevel-orderbfsstack
  • Math & Bit ManipulationEasyAuto-graded
    Exact Staffing for a 2:1 Nail-to-Screw Quota

    Compute the headcount of two specialist worker types so a component quota splits exactly 2:1 with every worker at full capacity, or report that no such staffing exists.

    Math & Bit Manipulationmathratiosdivisibilitymodular-arithmetic
  • Math & Bit ManipulationEasyAuto-graded
    Dice Duel Probability with Optional Blind Reroll

    Calculate the exact win probability in a dice duel where one player uses an optimal single blind reroll strategy.

    Math & Bit Manipulationmathprobabilitygreedy
  • StringsEasyAuto-graded
    Pick the Tightest Wildcard Mask for a Bit String

    Scan a list of 0/1/? templates, keep those that fit a bit string, and return the one with the fewest wildcards, breaking ties by earliest position.

    Stringsstringspattern-matchinglinear-scantie-breaking
  • Greedy & IntervalsHardAuto-graded
    Union Overlapping Road Pieces That Share a Straight Line

    Group integer-point polylines by the exact line they lie on, then merge overlapping or touching extents on each line into one sorted point list.

    Greedy & Intervalsintervalsgeometrygcdhashing
  • StringsEasyAuto-graded
    Query-Driven Text Wrapper with Last-Line Balancing

    Parse a URL query string by hand, then greedily wrap the text to a width and fix a lone last-line word by borrowing from the previous line.

    Stringsstring-parsinggreedysimulationtext-wrapping
  • Arrays & HashingEasyAuto-graded
    Find Peak Positions in an Integer Sequence

    Scan an integer list and return the indices of elements strictly larger than every neighbor that exists, handling the ends, plateaus, and tiny inputs correctly.

    Arrays & Hashingarraystraversalboundary-conditions
  • Arrays & HashingMediumAuto-graded
    Quickest Kilometer Within a Run Recorded in 5-Second Splits

    Find the highest average speed over any 1000 m stretch of a run given per-5-second distances, using prefix sums, binary search and interpolation at boundaries.

    Arrays & Hashingprefix-sumsbinary-searchsliding-windowinterpolation
  • Trees & GraphsMediumAuto-graded
    Group Staff Names by Reporting Depth

    Turn flat employee-manager records into a list of name groups by depth from the top manager, using a level-by-level breadth-first traversal.

    Trees & Graphsbfstreehash-maplevel-order
  • StringsMediumAuto-graded
    Longest Window With a Capped Number of Distinct Letters

    Find the length of the longest contiguous stretch of a string using no more than k different characters, testing the sliding-window technique with a frequency map.

    Stringssliding-windowtwo-pointershash-mapstrings
  • Math & Bit ManipulationMediumAuto-graded
    Fit a Line by Batch Gradient Descent with Standardized Input

    Implement full-batch gradient descent for a one-feature least-squares line, standardizing the input, and map the learned parameters back to the original scale.

    Math & Bit Manipulationgradient-descentlinear-regressionnumericalfeature-scaling
  • Dynamic ProgrammingMediumAuto-graded
    Climbing the Tallest Staircase Through a Height Map

    Find the longest chain of strictly rising values in a grid using only up, down, left, right steps, which tests DP over an implicit DAG with a valid processing order.

    Dynamic Programmingdynamic-programminggridtopological-ordermemoization
  • Arrays & HashingEasyAuto-graded
    Earliest Strict Valley in an Integer Sequence

    Scan an integer list for the leftmost interior value strictly smaller than both adjacent values, returning -1 if none exists, which tests boundary handling and strict comparisons.

    Arrays & Hashingarrayscanboundary-conditionsstrict-comparison
  • Data Structure DesignMediumAuto-graded
    Stream Merging Iterator for Two Ordered Sequences

    Simulate a stateful iterator that lazily combines two strictly sorted sequences into a single sorted, duplicate-free stream using constant space.

    Data Structure Designdesign-dsarraysheaps-sorting
  • Data Structure DesignMediumAuto-graded
    Wildcard Word Dictionary Simulator

    Simulate a word store that answers pattern queries where '.' stands for any single letter, which is best handled with a prefix tree and a depth-aware traversal.

    Data Structure Designtriedesignwildcarddfs
  • Heaps, Sorting & SearchEasyAuto-graded
    Last Stone Standing: Repeated Smash of the Two Heaviest Weights

    Simulate repeatedly removing the two largest values and reinserting their difference, using a max-heap to find the last remaining value or 0.

    Heaps, Sorting & Searchheappriority-queuesimulation
  • Trees & GraphsMediumAuto-graded
    Web Crawling Discovery and Bracket Syntax Check

    Perform a depth-bounded graph traversal over web pages based on domain filtering, and validate balanced brackets using a stack.

    Trees & Graphsbfsgraph-traversalstackstring-validation
  • Data Structure DesignMediumAuto-graded
    Sliding Window Stream Aggregator

    Design a memory-efficient real-time streaming data structure to query moving averages over a sliding temporal window.

    Data Structure Designsliding-windowdequedesignstream-processing
  • Trees & GraphsMediumAuto-graded
    Fast Power Residue Plus Nearest-Source Grid Map

    Combine square-and-multiply modular exponentiation with a multi-source BFS that labels every grid cell with its distance to the nearest source cell.

    Trees & Graphsbfsmodular-exponentiationgridmulti-source-bfs
  • Arrays & HashingMediumAuto-graded
    Chain-Reaction Tile Clearing on a Grid

    Simulate a grid game where runs of three or more equal tiles vanish together, tiles fall down, and the process repeats until the grid is stable.

    Arrays & Hashingsimulationmatrixtwo-pointersgrid
  • StringsEasyAuto-graded
    Valid Palindrome with At Most One Removal

    Determine whether a given string can be converted into a palindrome by removing no more than one character.

    Stringsstringstwo-pointers