KatInterview

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

Coding Interview Problems

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

5986
Problems
2219
Auto-graded
15
Topics
271
Added today

Showing 301–330 of 651 results

  • Data Structure DesignMediumModel answer
    Tackling Long-Winded Data Structure Design Problems Step by Step

    Describe a repeatable process for data-structure designs that are simple to state but long to code, then apply it to a price-time-priority limit order book.

    Data Structure Designdata-structure-designorder-bookinvariantslazy-deletion
  • Trees & GraphsMediumModel answer
    Resolve Out-of-Order Variable Assignments in a Mini Language

    Parse lines of integer assignments using only + and -, resolve forward and chained references, and report undefined names and cycles in a well-defined way.

    Trees & Graphstopological-sortparsingdependency-graphcycle-detection
  • Data Structure DesignMediumModel answer
    Build a Persistent Storage Layer for a Mini Database Engine

    Design and implement the last stage of a database engine: a catalog of databases, schemas, and tables plus durable row insert, read, update, and delete that survives restarts.

    Data Structure Designstorage-enginepersistencecrash-safetywrite-ahead-log
  • Data Structure DesignMediumModel answer
    Build a Run-Once Typewriter Component for a Hidden Token

    Build a React and TypeScript component that finds a hidden token in the DOM or over HTTP, types it out every 50ms, never replays the animation, cleans up after itself, and has Mocha tests.

    Data Structure Designreacttypescripthooksasync
  • Arrays & HashingMediumModel answer
    Cart Pricing Engine: Offers, Cheapest Deal, Aisle Sort

    Parse cart records, total units and price in integer cents, apply the best percent-off or buy-N-get-M-free deal per product, then sort items by aisle with frozen goods at the end.

    Arrays & Hashingparsingmoney-arithmeticextensible-designsorting
  • Trees & GraphsEasyModel answer
    Lone-Parity Filter and Leftmost Node Per Tree Depth

    Write one function that returns the elements whose even/odd class appears exactly once in an array, plus the first node's value at every depth of a binary tree.

    Trees & Graphsbfsbinary-treelevel-ordercounting
  • StringsHardModel answer
    Chunk-Safe Tokenizer for Fenced Code Blocks

    Design a stateful tokenizer that turns arbitrarily chunked Markdown into text and code-block events, correctly handling fences split across chunk boundaries.

    Stringsstreamingstate-machinestring-parsingmarkdown
  • Data Structure DesignMediumModel answer
    Frequency-Ranked Shuffle Without Repeats Per Round

    Build a player that ingests users' song lists and serves songs from most to least popular, never repeating a song until every known song has played once in the round.

    Data Structure Designheaplazy-deletionhash-mapdesign
  • Data Structure DesignHardModel answer
    Pattern Router for Sensor Topics with Placeholders and a Tail Wildcard

    Design a router that maps dot-separated topics to registered patterns with named placeholders and a trailing "**", using strict left-to-right precedence and backtracking.

    Data Structure Designtriebacktrackingroutingpattern-matching
  • Data Structure DesignMediumModel answer
    Live-Streaming Prompt Box with Incremental Reply Rendering

    Design and code a small front-end component that sends a prompt, renders a streamed reply as it arrives, blocks duplicate sends, supports cancel, and shows loading and error states.

    Data Structure Designfrontendreactstreamingasync-state
  • StringsHardModel answer
    Ordered Index Pairs Whose Concatenation Reads the Same Backwards

    Given distinct lowercase words, list every ordered index pair whose concatenation is a palindrome, doing much better than checking all pairs.

    Stringspalindrometriehashingkmp
  • Data Structure DesignMediumModel answer
    Pointers vs References in C++: Semantics and API Design

    Contrast C++ raw pointers with references, choose the right parameter and return types for four trading-engine APIs, and explain how aliasing affects optimization.

    Data Structure Designcpppointersreferencesapi-design
  • Data Structure DesignMediumModel answer
    Python Deep Dive: Concurrency, Generators, Typing and Memory

    Nine-part Python fundamentals review covering the GIL, concurrency models, decorators, generators, typing, packaging, profiling, memory management and exceptions.

    Data Structure Designpythongilconcurrencygenerators
  • Trees & GraphsHardModel answer
    Principal Types for a Tiny Lambda Calculus

    Build an AST for variables, lambdas and applications, then infer each expression's most general function type using unification, with an occurs check to reject infinite types.

    Trees & Graphstype-inferenceunificationhindley-milnerast
  • Trees & GraphsMediumModel answer
    Tallying a Tree of Message-Passing Processes

    Each tree node is an isolated process with only async send and blocking receive. Design a protocol so the root learns the tree size, tolerates lost and duplicate messages, and returns a structured result.

    Trees & Graphsdistributed-systemsconvergecastidempotencyretries
  • Math & Bit ManipulationMediumModel answer
    Stable Softmax, Sliding Variance and Balanced Partition

    Three short coding tasks: an overflow-safe softmax, an O(1) sliding-window variance with a ring buffer, and splitting positive integers into two groups with the smallest sum gap.

    Math & Bit Manipulationsoftmaxnumerical-stabilitywelfordsliding-window
  • Arrays & HashingMediumModel answer
    Scoring Parsed Payroll Form Output Against Ground Truth

    Write a scorer that compares fields extracted from tax forms to a ground-truth mapping, normalizing keys and currency, then reporting match rate, missing and mismatched fields, and precision/recall.

    Arrays & Hashingdata-normalizationhash-mapsevaluation-metricsprecision-recall
  • Data Structure DesignMediumModel answer
    Resilient Chargeback Inbox: Normalize, Cache, and Cancel in React

    Build a React dispute list that normalizes inconsistent API data, caches queries for 60 seconds, and avoids stale responses when filters or search change quickly.

    Data Structure Designreacttypescriptcachingrace-conditions
  • Data Structure DesignHardModel answer
    Eagerly Cached Cell Grid with Dependency Tracking

    Build a grid of cells that stores integers or sum formulas, keeps every value precomputed for constant-time reads, and refuses any write that would introduce a circular reference.

    Data Structure Designgraphtopological-sortcycle-detectioncaching
  • Data Structure DesignEasyModel answer
    Layered Scopes for a Key-Value Store with Savepoints

    Build an in-memory key-value store whose writes can be grouped into nested, revertable scopes that either merge into the enclosing scope or are thrown away.

    Data Structure Designstackhash-mapdesignscoping
  • Data Structure DesignMediumModel answer
    Run Work Items on Manual Python Threads and Debug Them in Linux

    Fan a function out over a list using a fixed number of hand-made Python threads, capture every result or error, join cleanly, then inspect the live threads from the Linux shell.

    Data Structure Designpythonthreadingconcurrencylinux
  • Math & Bit ManipulationMediumModel answer
    Bit-Level Speedups for a Hot Integer Loop

    Choose bit-twiddling techniques that cut branch mispredictions and memory traffic in a tight integer loop, justify their correctness, and reason about their CPU and cache effects.

    Math & Bit Manipulationbit-manipulationbranchlesspopcountperformance
  • Data Structure DesignMediumModel answer
    Fixing a Lost-Update Race in a Deposit Method You Cannot Edit

    Diagnose the race in an account deposit that reads, pauses, then writes, and add locking through a subclass, wrapper or embedding in Python and Go without touching the original type.

    Data Structure Designconcurrencyrace-conditionmutexpython
  • Data Structure DesignHardModel answer
    Retroactive Pay Ledger with Rate Changes and Shift Logging

    Design a class that records rate changes and shifts in any order, and reports total earnings under the current rate schedule using prefix sums and binary search.

    Data Structure Designdesignprefix-sumbinary-searchintervals
  • Data Structure DesignMediumModel answer
    Org Chart Inference with Manager and Peer Links

    Design a structure that records manager and same-manager links between employee IDs and answers whether one employee sits above another, including facts inferred from earlier updates.

    Data Structure Designunion-finddesigngraphstransitive-closure
  • Arrays & HashingMediumModel answer
    Merging k Key-Value Maps: Conflict Rules and Efficient Design

    Design a way to merge two key-value maps, extend it to k maps, and decide which conflict rules must be pinned down before writing any code.

    Arrays & Hashinghash-mapmergingapi-designclarifying-questions
  • Heaps, Sorting & SearchMediumModel answer
    Streaming Word Frequencies from an Oversized Text File

    Build a memory-safe word counter for a huge text file, define tokenization rules, return the top-k words deterministically, and discuss what to do when the vocabulary strains memory.

    Heaps, Sorting & Searchword-countstreaminghash-maptop-k
  • Trees & GraphsMediumModel answer
    Crawl a Web-Served Labyrinth Through Unreliable Responses

    Write a crawler that explores a maze of HTTP endpoints to find the exit, coping with cycles, transient 503 errors and malformed JSON, while guaranteeing termination.

    Trees & Graphsgraph-traversalbfshttpretries
  • StringsMediumModel answer
    Bootstrapping a Reproducible Python Environment with Bash

    Write and explain a Bash script that creates or reuses a Python virtual environment and installs dependencies, covering strict mode, idempotency, activation pitfalls, and resulting files.

    Stringsbashshell-scriptingpython-venvautomation
  • Data Structure DesignMediumModel answer
    Card Prefix Registry with Per-Field Trust Resolution

    Design an in-memory registry mapping digit prefixes to brand and card type, resolving each field by longest prefix, then trust, then recency, with fast lookups.

    Data Structure Designhash-maplongest-prefix-matchtriedata-structure-design