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 151–180 of 650 results

  • Trees & GraphsMediumModel answer
    Modeling Classic Puzzles: River Crossing, Jugs, and Proofs

    Turn a set of contest-style logic puzzles, led by the fox-chicken-grain river crossing, into formal models, and give algorithms with proofs of correctness and optimality.

    Trees & Graphsbfsstate-space-searchinvariantsproofs
  • Arrays & HashingMediumModel answer
    Distance-to-Go Along Batched 2D Routes

    Given a batch of 2D routes, compute for each waypoint the length of the remaining route to the final waypoint, in linear time, handling short and empty inputs.

    Arrays & Hashingsuffix-sumnumpyvectorizationeuclidean-distance
  • Data Structure DesignMediumModel answer
    Object Model and Move Engine for a Sliding-Tile Merge Game

    Design the classes and core move algorithm for a configurable N x N sliding-tile merge puzzle, with testable randomness, win and loss detection, and room for undo.

    Data Structure Designobject-oriented-designgame-logicsimulationdependency-injection
  • Data Structure DesignMediumModel answer
    Build an Expiring LRU Cache with an Injectable Clock

    Design a fixed-capacity cache with least-recently-used eviction and per-entry expiry, and justify your data structures, tests and complexity.

    Data Structure Designlru-cacheordereddictttlunit-testing
  • Math & Bit ManipulationHardModel answer
    Balanced Character Rewriting and Offline Grid Threshold Queries

    Solve parity-based string transformation via bitmasks and handle offline 2D range count queries using dynamic point-update data structures.

    Math & Bit Manipulationbit-manipulation2d-fenwick-treesweep-lineprefix-sum
  • Data Structure DesignMediumModel answer
    How Hash Tables Handle Collisions, Deletes, and Growth

    Walk through hash table internals: index mapping, chaining versus linear probing, safe deletion, load-factor resizing, and when operations degrade from O(1) to O(n).

    Data Structure Designhash-tablecollision-resolutionlinear-probingload-factor
  • Stacks & QueuesMediumModel answer
    Troubleshooting Silent Execution in Python Async Workflows

    Analyze and fix a Python async script that finishes silently without invoking its async functions, and explore concurrent execution options with asyncio.

    Stacks & Queuespythonasyncioconcurrencydebugging
  • Data Structure DesignHardModel answer
    Boolean Condition Trees for a Spending Policy Checker

    Design a data-driven policy engine whose rules combine field checks with nested AND, OR and NOT, covering representation, validation, missing-field behavior and explainable results.

    Data Structure Designexpression-treerules-enginevalidationboolean-logic
  • Data Structure DesignMediumModel answer
    C++ Polymorphism: Overridable Methods vs Mandatory Interface Methods

    Explain how C++ virtual and pure virtual functions differ, how vtable dispatch works, when a class is abstract, and how virtual destructors affect safe cleanup.

    Data Structure Designcpppolymorphismvtableabstract-classes
  • Data Structure DesignMediumModel answer
    Design a Resilient In-Memory Task Queue with Worker Failure Handling

    Build a thread-safe, in-process job queue that handles worker crashes, lease timeouts, late reports, and retry bounds using deterministic testing mechanics.

    Data Structure Designdesign-dsstacks-queuesconcurrencythreads
  • Stacks & QueuesMediumModel answer
    Simulated Stock Trading Signals and Two-Char String Reduction

    Solve two streaming state problems: daily stock trading based on sign patterns in O(N) time and two-character substring elimination using an in-place stack.

    Stacks & Queuesstacks-queuesarraysstringsmath-bits
  • StringsEasyModel answer
    Round Decimal Strings to a Power-of-Ten Step, No Floats

    Round a decimal string to the nearest integer, then to a power-of-ten step such as 100 or 0.1, using only string and digit operations and a clearly stated tie-breaking rule.

    Stringsstringsroundingbig-numberscarry
  • Data Structure DesignMediumModel answer
    Non-Blocking Concurrent Log Writer with Bounded Buffer

    Build a thread-safe logger whose callers never wait on slow sink I/O, preserving submission order, bounding memory, and flushing every accepted message on shutdown.

    Data Structure Designconcurrencyproducer-consumerbounded-queuebackpressure
  • Data Structure DesignMediumModel answer
    Build an In-Memory Ledger with Deposits and Transfers

    Implement an in-memory ledger class supporting account creation, deposits and transfers, with clear return codes, invariants, retry safety and concurrency choices.

    Data Structure Designhash-mapclass-designidempotencyconcurrency
  • Heaps, Sorting & SearchMediumModel answer
    Quicksort vs Mergesort: Hardware, Stability and Disk Trade-offs

    Compare two O(n log n) sorts by how they use caches, preserve tie order, resist bad inputs, and behave when data lives on disk instead of in memory.

    Heaps, Sorting & Searchquicksortmergesortstabilitycache-locality
  • Data Structure DesignMediumModel answer
    Slot Availability Queries on a Sparse Number Line

    Handle an online stream of point-blocking and window-clearance queries on a huge integer line, and return a bit string with one result per query.

    Data Structure Designbinary-searchsorted-structuresfenwick-treecoordinate-compression
  • Stacks & QueuesMediumModel answer
    Build a Stack-Based Mini Language Interpreter in Python

    Write an interpreter that parses a line-based program of LOAD, STORE and integer arithmetic instructions, runs it on an operand stack, and returns the final variable memory.

    Stacks & Queuesinterpreterstackparsingerror-handling
  • Heaps, Sorting & SearchMediumModel answer
    Two-Sided Order Book Matching with Unit Orders

    Simulate a simple exchange: buys and sells of size one arrive in sequence, cross against the best resting price, and you return the total value of all executed trades.

    Heaps, Sorting & Searchheappriority-queuesimulationorder-book
  • Data Structure DesignMediumModel answer
    Build an In-Memory File Store with Quotas and Backups

    Implement an in-memory file store with prefix top-N queries, per-user quotas, user merging, and per-user backup and restore that never disturb other users.

    Data Structure Designdata-structure-designhash-mapheapin-memory-storage
  • Data Structure DesignMediumModel answer
    Reversible Wallet Balance Tracker with Undo and Redo

    Design an in-memory wallet class that applies relative changes and absolute resets to an integer-cent balance, with full undo and redo and constant-time operations.

    Data Structure Designdesignundo-redostackscommand-pattern
  • Data Structure DesignMediumModel answer
    Review a Fit/Transform Preprocessing Module and Write a Key Test

    Review a small Python preprocessing module with an outlier-capping class and three imputers: explain its purpose, justify fit/transform separation, critique style and imports, and write one key unit test.

    Data Structure Designpythoncode-reviewscikit-learnunit-testing
  • Data Structure DesignMediumModel answer
    Single-Open Async Tooltip Panels with Keyboard Support in React

    Design a React popover that fetches data when opened, stays exclusive across many triggers, ignores stale responses, and handles focus, Esc, and outside clicks accessibly.

    Data Structure Designreactaccessibilityrace-conditionsfocus-management
  • Data Structure DesignMediumModel answer
    Pluggable Scoring Pipeline for Ranking Concert and Show Listings

    Design an object-oriented ranking engine where scoring and filtering rules can be chained, weighted, reordered and isolated from failures, with a backfill tier when too few results come back.

    Data Structure Designobject-oriented-designstrategy-patternrankingfallback
  • Data Structure DesignMediumModel answer
    Build a CSV Data Frame and Assembly of Sequence Fragments

    Parse RFC 4180 CSV into an in-memory table with query support, and reconstruct chained sequences from directed or undirected overlapping fragments.

    Data Structure Designdesign-dsstringstrees-graphs
  • Data Structure DesignMediumModel answer
    Build a Bucketed Spatial Index for Planar Points

    Implement a region quadtree that stores 2D points in capacity-limited buckets, splits into four quadrants on overflow, and answers rectangular range queries efficiently.

    Data Structure Designquadtreespatial-indexrecursionrange-query
  • Data Structure DesignMediumModel answer
    Build a Bounded Permit Task Execution Engine

    Implement a concurrency manager that controls variable permit usage per task, supports blocking and asynchronous execution, and guarantees safe permit releases.

    Data Structure Designconcurrencysynchronizationdesign-dsthreading
  • Trees & GraphsMediumModel answer
    Feature Flag Rollout Validator with Dependency Cycle Detection

    Parse feature dependency specs, run modular checksum verification, and evaluate user eligibility and feature graph dependencies while handling cyclic rollouts.

    Trees & Graphstrees-graphsstringsdepth-first-search
  • Data Structure DesignMediumModel answer
    Build a Biased Index Picker Using Cumulative Totals

    Design a class that returns an index at random with probability proportional to its weight, then explain how to make each draw fast and how to handle updates.

    Data Structure Designprefix-sumbinary-searchrandom-samplingfenwick-tree
  • StringsMediumModel answer
    Java Code Review: Refactoring a CSV Generator

    Analyze a poorly designed Java method for generating CSV strings and detail performance, RFC 4180 compliance, memory usage, and security enhancements.

    Stringscode-reviewjavastringscsv
  • Trees & GraphsHardModel answer
    Topological Task Scheduler and Strict Expression Parser

    Solve a task dependency ordering problem via topological sort and build an expression evaluator supporting custom operator precedence, unary signs, and overflow checks.

    Trees & Graphstopological-sortgraph-algorithmsexpression-parserstacks