KatInterview

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

Coding Interview Problems

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

5974
Problems
2212
Auto-graded
15
Topics
269
Added today

Showing 121–150 of 2112 results

  • Data Structure DesignMediumAuto-graded
    Point-in-Time Set Views from an Operation Log

    Simulate a set that processes add, remove, contains and snapshot operations, where each snapshot must be an independent frozen copy of the set at that moment.

    Data Structure Designdesignhash-setsnapshotsimulation
  • Data Structure DesignMediumAuto-graded
    Simulate a Fixed-Size Cache Under LRU or LFU Eviction

    Replay a list of get/put operations on a bounded cache that evicts by recency or by frequency (ties broken by recency), and return the result of each operation.

    Data Structure Designhash-mapordered-dictlrulfu
  • Arrays & HashingMediumAuto-graded
    Distinct Value Foursomes Hitting a Target Total

    Find every distinct set of four values, taken from different positions, that add up to a target, with no repeated value combinations in the output.

    Arrays & Hashingtwo-pointerssortingdeduplicationk-sum
  • Arrays & HashingEasyAuto-graded
    Count Shoppers With Visits on Two or More Days

    Group log entries by person and ignore repeats on the same day, then count how many people appear on at least two different calendar days.

    Arrays & Hashinghash-sethash-mapgroupingdeduplication
  • Stacks & QueuesMediumAuto-graded
    Collapse Adjacent Edits Before Applying Them to a Text Buffer

    Simulate a queue of insert and format edits, merging adjacent inserts and dropping repeated adjacent formats, then return the final text and ordered list of applied styles.

    Stacks & Queuesstacksimulationcommand-patternstrings
  • Data Structure DesignMediumAuto-graded
    Ring-Buffer Deque with Constant-Time Indexing

    Build a double-ended queue on a resizable circular array so index lookups are O(1), then replay a command list against it and report each result.

    Data Structure Designcircular-bufferdequedynamic-arrayamortized-analysis
  • Trees & GraphsMediumAuto-graded
    Extract Text From Matching Elements in Messy Markup

    Parse a forgiving HTML string into an element tree in one pass, then collect each matching element's combined text in document order using an iterative depth-first traversal.

    Trees & Graphsparsingtreedfsstack
  • Trees & GraphsMediumAuto-graded
    Total Value of Bit-Strings Along a Tree's Leaf Paths

    Decode a level-order bit tree with skipped None slots, then sum the binary values read along each root-to-leaf path, testing BFS parsing and DFS with a running accumulator.

    Trees & Graphsbinary-treedfsbfslevel-order-parsing
  • Heaps, Sorting & SearchMediumAuto-graded
    Evaluate a Broken-Line Curve at a Query Position

    Sort scattered points by x, then find the y on the connecting line at a query x, interpolating inside the range and extending the end segments outside it.

    Heaps, Sorting & Searchbinary-searchsortinginterpolationgeometry
  • Greedy & IntervalsMediumAuto-graded
    Combine Overlapping Time Intervals

    Consolidate overlapping and adjacent closed intervals into a minimal list of disjoint intervals using sorting.

    Greedy & Intervalsarraysgreedy-intervalssorting
  • Heaps, Sorting & SearchMediumAuto-graded
    Order Transformed Values of a Sorted Array

    Apply a quadratic mapping to a sorted list of numbers and return the sorted results in O(n) time.

    Heaps, Sorting & Searchtwo-pointersarraysmath
  • Trees & GraphsMediumAuto-graded
    Closest-Pair Dispatch of Couriers on a Walled Grid

    Match couriers to parcels by repeatedly choosing the globally closest pair, using BFS shortest paths on a grid with walls and deterministic tie-breaking.

    Trees & Graphsbfsgridgreedysorting
  • Stacks & QueuesMediumAuto-graded
    Normalize a Filesystem Location String

    Reduce an absolute Unix-style path to its canonical form by resolving repeated slashes, current-directory and parent-directory segments, using a stack.

    Stacks & Queuesstackstring-parsingsimulationpaths
  • Math & Bit ManipulationMediumAuto-graded
    Count Starting Numbers for Consecutive Sums

    Determine how many positive integers can serve as the starting element of a sequence of consecutive positive integers that sums to a target value.

    Math & Bit Manipulationmathnumber-theoryarithmetic-progression
  • Trees & GraphsMediumAuto-graded
    Find the k-th Value in a Level-Order Encoded Tree's Inorder Sequence

    Decode a level-order binary tree with null gaps, then return the k-th value in its inorder sequence, or -1 if fewer than k nodes exist.

    Trees & Graphsbinary-treeinorder-traversaliterative-traversalstack
  • Arrays & HashingMediumAuto-graded
    Cascading Tile Crush on a Grid

    Simulate a tile-crush game: mark all runs of 3+ equal tiles, clear them, drop tiles with gravity, and repeat until stable, counting removed tiles.

    Arrays & Hashingsimulationmatrixtwo-pointersgrid
  • Trees & GraphsMediumAuto-graded
    Inherited Permissions Across a Group Hierarchy

    Answer permission queries over a DAG of groups where each group inherits from its parents, using graph traversal with memoization or caching.

    Trees & Graphsgraphdagdfsmemoization
  • Trees & GraphsMediumAuto-graded
    Best Hub-and-Spokes Value Sum with a Spoke Limit

    Choose a hub node and up to k adjacent nodes to maximize the total node value, which tests per-node greedy selection over adjacency lists.

    Trees & Graphsgraphgreedysortingadjacency-list
  • Dynamic ProgrammingMediumAuto-graded
    Biggest Solid Block in a Binary Grid

    Find the area of the largest square made only of '1' cells in a grid of character digits, using a dynamic programming recurrence that can be compressed to a single row of state.

    Dynamic Programmingdynamic-programmingmatrixspace-optimization2d-grid
  • Stacks & QueuesEasyAuto-graded
    Leftover Brackets After Pairing Up a Parenthesis String

    Count the parentheses left over after forming the maximum number of valid "(" before ")" pairs, testing a greedy counter scan or stack over a string.

    Stacks & Queuesstackgreedystringsparentheses
  • Trees & GraphsMediumAuto-graded
    Reach the Goal State While Avoiding Forbidden Nodes

    Decide whether a goal node can be reached from node 0 in a directed graph without ever stepping on a forbidden node, using BFS or DFS reachability.

    Trees & Graphsgraphbfsreachabilitydirected-graph
  • Trees & GraphsMediumAuto-graded
    First Moment a Cable Network Becomes One Piece

    Replay unsorted timed link events and find the earliest timestamp at which every node is in one connected group, using union-find over events sorted by time.

    Trees & Graphsunion-findgraph-connectivitysortingkruskal
  • Data Structure DesignMediumAuto-graded
    Simulate Stacked Rectangles on a Small Text Canvas

    Simulate add, remove, reorder and render commands on a layered character canvas, resolving overlaps by layer order and clipping shapes at the edges.

    Data Structure Designsimulationordered-dictdesignclipping
  • Greedy & IntervalsMediumAuto-graded
    Most Overlapped Aisle Along a Line of Lamps

    Find the integer position covered by the most symmetric intervals, returning the smallest on ties, using an event sweep over interval endpoints instead of visiting every position.

    Greedy & Intervalssweep-lineintervalsdifference-arraysorting
  • Arrays & HashingMediumAuto-graded
    Zigzag Parity Check on Subarray Ranges

    Answer many range queries asking whether neighbors in a subarray always differ in odd/even parity, using prefix counts of same-parity adjacent pairs.

    Arrays & Hashingprefix-sumrange-queriesparityarrays
  • Greedy & IntervalsMediumAuto-graded
    Max Speed Continuous Window on Ticked Rate Stream

    Find the maximum average throughput over a continuous time window of a specified size, given rate logs over uniform time ticks.

    Greedy & Intervalssliding-windowtwo-pointersgreedyprefix-sum
  • Arrays & HashingEasyAuto-graded
    Word-Count Cosine Score for Two Text Strings

    Compute the cosine of the angle between the word-frequency vectors of two strings, using a hash-map counter and guarding against empty inputs.

    Arrays & Hashinghash-mapcountingstringsmath
  • Arrays & HashingMediumAuto-graded
    Count Squares Spanned by Crossing Vertical and Horizontal Segments

    Count axis-aligned squares whose four corners all lie where a vertical segment meets a horizontal one, using per-row bitmasks and pairwise row comparison.

    Arrays & Hashinggeometrybitmaskhashingenumeration
  • Data Structure DesignMediumAuto-graded
    Log Record Dedup: Batch Merge and Watermarked Replay

    Deduplicate log records by event id under a first or latest policy, then replay an operation list through a watermark-based stream deduplicator that drops late data and evicts finalized entries.

    Data Structure Designhash-mapsortingstreamingwatermark
  • Trees & GraphsMediumAuto-graded
    Indented Staff Listing from Direct-Report Pairs

    Build a forest from (employee, manager) pairs and output each person with their depth in a sorted depth-first order, handling very deep chains iteratively.

    Trees & Graphstreedfsforesthash-map