KatInterview

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

Coding Interview Problems

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

5971
Problems
2211
Auto-graded
15
Topics
272
Added today

Showing 91–120 of 650 results

  • Data Structure DesignHardModel answer
    Variable-Argument Functions Across Languages, with a Safe Logger

    Compare how two languages implement functions with a variable number of arguments, then design a type-checked key-value logger that avoids injection and needless allocation.

    Data Structure Designvariadic-functionstype-safetycalling-conventionslogging
  • Data Structure DesignMediumModel answer
    Multi-Device Login Burst Detector over a Late-Tolerant Stream

    Design a streaming detector that flags users with 4 or more distinct devices logging in successfully within 10 minutes, tolerating events up to 30 seconds late, with bounded memory.

    Data Structure Designsliding-windowstreamingwatermarkordered-map
  • Data Structure DesignMediumModel answer
    Build a Terminal Block-Stacking Game Engine

    Design a testable, terminal-friendly engine for a falling-block puzzle on a 10x20 grid, covering movement, rotation, gravity, locking, line clearing and game over.

    Data Structure Designgame-logicstate-machinesimulationobject-oriented-design
  • Trees & GraphsMediumModel answer
    Robot Navigation on a Hidden Grid with DFS and Backtracking

    Guide a robot through a map it can only discover step by step, reaching the target with no repeated visits, real backtracking, and a clear result when the target is unreachable.

    Trees & Graphsdfsbacktrackinggraph-traversalgrid
  • Trees & GraphsMediumModel answer
    Sliding Block Minimums and Dependency-Ordered Cooking Plan

    Compute the minimum of every K x K window in a grid, then order recipes so that every derived ingredient is made before the dish that uses it, detecting cycles.

    Trees & Graphstopological-sortmonotonic-dequesliding-windowkahns-algorithm
  • StringsMediumModel answer
    Define and Implement a Streaming Unicode Word Counter

    Specify precise tokenization rules for counting words in text, then build a Unicode-aware counter that works on huge streams, with tests and a regex versus scanner comparison.

    Stringstokenizationunicodestreamingstate-machine
  • Greedy & IntervalsMediumModel answer
    Trim Overlapping Ranges to Limit Capacity

    Truncate overlapping integer intervals so no point is covered by more than k ranges while minimizing the total removed coverage.

    Greedy & Intervalsintervalssweep-lineheapgreedy
  • Data Structure DesignMediumModel answer
    Building a Multi-Level Credit Ledger with Timed Transfers and Merges

    Build an in-memory ledger of credit-holding workspaces in four stages: transfers with a top-k ranking, timed transfers with cancellation, workspace merges, and point-in-time balance lookups.

    Data Structure Designclass-designheapbinary-searchsimulation
  • Data Structure DesignMediumModel answer
    Prefix-Caching Transform Runner with Single-Flight and LRU

    Build a thread-safe runner for chains of deterministic byte transforms that reuses cached prefixes, collapses concurrent duplicate work into one execution, and bounds memory with LRU eviction.

    Data Structure Designconcurrencylru-cachehashingsingle-flight
  • Math & Bit ManipulationMediumModel answer
    Build an Endless Fibonacci Stream with Python Generators

    Explain how lazy evaluation works in Python and write a generator that yields Fibonacci numbers indefinitely, with safe ways to consume it and the reasoning behind its state handling.

    Math & Bit Manipulationpythongeneratorslazy-evaluationfibonacci
  • Trees & GraphsMediumModel answer
    Find a Money-Making Loop in a Table of Exchange Rates

    Given directed currency exchange quotes, decide whether some round trip returns more than it started with, and output one such round trip as an ordered list of currencies.

    Trees & Graphsgraphbellman-fordnegative-cyclefloating-point
  • Arrays & HashingMediumModel answer
    Cyclic Shifts and Cell-Level Keyword Lookup in CSV Text

    Shift an integer array left or right by k using modular arithmetic, then locate every occurrence of one or more keywords in a simple CSV string, reporting row, column and offset in the cell.

    Arrays & Hashingarray-rotationmodular-arithmeticstring-searchcsv-parsing
  • Data Structure DesignMediumModel answer
    Build a Sampler That Picks Items in Proportion to Mutable Weights

    Design a structure holding items with positive integer weights that supports insert, delete and a weight-proportional random pick, each in logarithmic time.

    Data Structure Designfenwick-treeweighted-samplingrandomizationdata-structure-design
  • Data Structure DesignMediumModel answer
    Dealing and Ranking Three-Card Hands With an Extensible Rule Set

    Build a small card game that deals three cards per player from one deck, ranks hands by category, picks the winner, then extend the ranking with a suit-based category.

    Data Structure Designobject-oriented-designsimulationcomparisonextensibility
  • Data Structure DesignMediumModel answer
    Searchable Dropdown Input with Live Async Suggestions in React

    Implement a React search box whose dropdown fills with suggestions from an abortable async source and works fully by keyboard and mouse, without ever showing outdated results.

    Data Structure Designreacthooksasyncaccessibility
  • Data Structure DesignHardModel answer
    Dynamic Room Occupancy Tracker with Top-K Ranking Query

    Design an in-memory system tracking occupancy and entry times across rooms, returning the busiest rooms in optimal logarithmic time per update.

    Data Structure Designdesign-dsheaps-sortinghash-map
  • StringsMediumModel answer
    Build a Streaming Lisp-Style Expression Reader with Exact Error Positions

    Write a single-pass reader for a small Lisp-like syntax with integers, symbols and nested lists, reporting the first error with a clear message and exact character index.

    Stringsparsingrecursive-descenterror-handlings-expression
  • Data Structure DesignMediumModel answer
    Designing a Validated In-Memory Cache for Repeated Parsing

    Speed up a script that repeatedly parses files by adding a thread-safe, bounded, in-memory cache, and justify its keys, eviction, staleness checks and complexity.

    Data Structure Designcachinghash-maplruconcurrency
  • Stacks & QueuesMediumModel answer
    Build a Tiny Expression Language Interpreter in Three Stages

    Implement a lexer, recursive-descent parser and evaluator for a small integer language with variables, unary minus, precedence, truncating division and print.

    Stacks & Queuesparsinginterpreterrecursive-descentast
  • Data Structure DesignMediumModel answer
    Design a Safe, Idempotent Auto-Approval Engine for Order Refunds

    Design and code a refund decision engine that applies pluggable rules, never refunds more than was paid, and handles retried or concurrent requests without paying twice.

    Data Structure Designdomain-modelingidempotencyrules-enginemoney-handling
  • Data Structure DesignHardModel answer
    Design a Tree-Based Storage Simulator with Auto-Renaming

    Build an in-memory file store that auto-creates parent folders, renames clashing files with the lowest free numeric tag, and lists folder contents in ASCII order.

    Data Structure Designdesigntreehash-setstrings
  • Data Structure DesignMediumModel answer
    Pluggable Payment Dispatch with Spring Bean Maps

    Design an extensible payment dispatcher in Spring where a Map of strategy beans is injected automatically and new payment methods need no changes to the service.

    Data Structure Designjavaspringstrategy-patternsolid
  • Data Structure DesignMediumModel answer
    BST In-Order Traversal Flow & Priority Queue Dispatcher

    Implement an in-order tree iterator with memory constrained by height, followed by a priority queue that handles multi-attribute ordering rules.

    Data Structure Designtreesstackheappriority-queue
  • Math & Bit ManipulationMediumModel answer
    Compute Courier Compensation for Delivery Trips

    Calculate total delivery earnings from start/end times and distances using conditional rates, rush-hour multipliers, and precision rules.

    Math & Bit Manipulationmathparsingsimulation
  • Trees & GraphsHardModel answer
    Shortest Hop Count Through a Flaky Web Graph

    Crawl a website graph from a start URL to an exit page using BFS, retrying transient 5xx failures a limited number of times, and return the minimum hop count or -1.

    Trees & Graphsbfsgraph-traversalretry-logicvisited-set
  • Stacks & QueuesMediumModel answer
    Arithmetic String Calculator with Operator Precedence

    Compute the integer result of a string holding non-negative numbers, four operators and spaces, honoring precedence and truncating division, without eval and with linear time.

    Stacks & Queuesparsingstackstringoperator-precedence
  • Data Structure DesignMediumModel answer
    Modeling a Multi-Car Lift Dispatcher with Swappable Policies

    Design an object-oriented lift (elevator) control system: classes, per-car state machine, stop ordering, pluggable dispatch, edge cases, and testable core logic.

    Data Structure Designobject-oriented-designstate-machinestrategy-patternsimulation
  • Data Structure DesignMediumModel answer
    Building a Cache-Friendly Lookup Table for a Hot Loop

    Design a hash table for a performance-critical inner loop, covering collision strategy, memory layout, probing, load factor, prefetching, and how to benchmark it.

    Data Structure Designhash-tableopen-addressingsimdcache-optimization
  • Greedy & IntervalsMediumModel answer
    Decode Non-Overlapping Keyphrase Spans from BERT Logits

    Implement a decoder that converts token start and end logits into non-overlapping character spans using offset mappings and greedy selection.

    Greedy & Intervalsstringsgreedy-intervalsmachine-learningsorting
  • Data Structure DesignHardModel answer
    Greedy Longest-Match Subword Encoder Built on a Byte Trie

    Design and implement a deterministic subword encoder that uses a trie for longest-match lookup, with lossless Unicode handling, versioned vocabularies, tests, and a comparison with BPE and WordPiece.

    Data Structure Designtrietokenizerunicodenlp