KatInterview

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

Coding Interview Problems

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

5978
Problems
2214
Auto-graded
15
Topics
272
Added today

Showing 181–210 of 2764 results

  • 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
  • Data Structure DesignMediumModel answer
    Build a Fire-Once Event Gate for Concurrent Threads

    Design a thread-safe one-shot event gate with fire, timed wait and non-blocking status check, avoiding lost wakeups, spurious-wakeup bugs and busy-waiting.

    Data Structure Designconcurrencycondition-variablethreadingsynchronization
  • Data Structure DesignMediumModel answer
    Weighted Random Picker with Live Weight Updates

    Build a container that returns items at random with probability proportional to their weights, supports re-weighting existing items, and keeps picks fast and memory small.

    Data Structure Designfenwick-treeprefix-sumsrandom-samplingbinary-search
  • Trees & GraphsMediumAuto-graded
    Split a Nested Structure into Values and a Shape Template

    Implement a single function that extracts leaves and a shape template from nested lists and dicts, then rebuilds the original from them, testing recursion and traversal order.

    Trees & Graphsrecursiondfsnested-structuresdictionaries
  • Data Structure DesignHardAuto-graded
    Credit Ledger Simulator with Merges and Delayed Rewards

    Simulate a timestamped ledger with deposits, transfers, spends with delayed cashback, account merges and spend rankings, using union-find and a min-heap.

    Data Structure Designdesignunion-findheapsimulation
  • Arrays & HashingMediumAuto-graded
    Check Whether Two Custom Dice Give a Flat Sum Distribution

    Decide whether two lists of die-face labels make every total from 1 to 12 appear exactly three times across all 36 face pairings, using pair counting.

    Arrays & Hashingcountinghash-mapenumerationprobability
  • Math & Bit ManipulationMediumAuto-graded
    Growing Worker Pool Sized by Peak Load Readings

    Track a pool that only grows, sized to cover each load reading with fixed-capacity workers; tests ceiling division and running-maximum reasoning with large values.

    Math & Bit Manipulationsimulationprefix-maximumceiling-divisionarrays
  • Data Structure DesignMediumAuto-graded
    Expiring Key-Value Store Driven by a Virtual Clock

    Simulate a key-value store with per-key expiry on a manual clock, handling overwrites, deletes and cleanup of expired entries via a command list.

    Data Structure Designdesignhash-mapheapttl
  • Heaps, Sorting & SearchMediumAuto-graded
    Largest Threshold Met by Daily Step Counts

    Find the largest integer k such that at least k entries in a list are at least k, testing sorting or counting-based selection and reasoning about monotone thresholds.

    Heaps, Sorting & Searchsortingcountingh-indexarrays
  • Data Structure DesignMediumModel answer
    Build a Wildcard-Aware URL Router with Literal Priority

    Design a router that stores path templates with {name} wildcards and resolves concrete paths to a handler plus captured values, preferring exact segments and backtracking when they dead-end.

    Data Structure Designtriebacktrackingroutingstring-parsing
  • Dynamic ProgrammingHardAuto-graded
    Adaptive Word Guessing Minimax Strategy

    Find the minimum number of worst-case letter guesses required to isolate a hidden word against an adversarial host.

    Dynamic Programmingdynamic-programmingbit-manipulationminimaxmemoization
  • Greedy & IntervalsMediumAuto-graded
    Peak Crew Size for Scheduled Shifts

    Compute the smallest crew that covers every scheduled task by finding the peak simultaneous demand, treating each task as half-open and parsing HH:MM times.

    Greedy & Intervalssweep-lineintervalsgreedysorting
  • Data Structure DesignHardModel answer
    In-Memory Bank With Delayed Payments, Cancellation and Spend Ranking

    Extend an in-memory bank with delayed payments that can be canceled, record success or failure for each, discard stale entries, and rank accounts by total outgoing money.

    Data Structure Designdesign-dsheaplazy-deletionsimulation
  • Dynamic ProgrammingMediumAuto-graded
    Best Final Score from Affine Card Purchases Under a Budget

    Choose a budget-limited subset of cards and an order to maximize a score updated by an affine rule, testing subset and ordering search and exchange-argument reasoning.

    Dynamic Programmingsubset-searchpermutationsexchange-argumentknapsack