KatInterview

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

Coding Interview Problems

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

5969
Problems
2211
Auto-graded
15
Topics
273
Added today

Showing 61–90 of 650 results

  • Trees & GraphsMediumModel answer
    Mapping a Hidden Maze: Shortest Route for a Sensing Robot

    A robot in an unseen grid senses neighbours for free and pays per move. Find a shortest route to a target, or return to the start and report failure if none exists.

    Trees & Graphsbfsgridonline-explorationshortest-path
  • Trees & GraphsMediumModel answer
    Right Edge of a Tree and Minimal Bracket Removal

    Two linked tasks: list the nodes visible from the right of a binary tree, and delete the fewest parentheses from a string so the rest is balanced.

    Trees & Graphsbinary-treebfsstackstrings
  • Data Structure DesignMediumModel answer
    What Java's volatile Does and Does Not Guarantee

    Explain the Java Memory Model guarantees of volatile fields: visibility, happens-before ordering and reordering limits, its gaps such as compound atomicity, and when to prefer locks or atomics.

    Data Structure Designjavaconcurrencymemory-modelvolatile
  • Data Structure DesignHardModel answer
    Append-Only Log Storage Engine with Torn-Write Recovery

    Build an embedded byte-oriented key-value store on a checksummed append-only log, with an in-memory index, delete markers, thread safety and recovery that truncates a damaged tail.

    Data Structure Designstorage-engineappend-only-logcrash-recoverycrc32
  • Trees & GraphsMediumModel answer
    Friend Product Suggestions and Click-Path Reachability

    Two short coding tasks: suggest products that a user's friends bought but the user hasn't, and decide whether one URL can reach another through recorded navigation steps.

    Trees & Graphshash-setset-differencegraphbfs
  • StringsMediumModel answer
    Verify Validity of Piece Movement on a 1D Board

    Determine whether an initial 1D board configuration can reach a target configuration based on specific movement and jump rules.

    Stringsstringstwo-pointersinvariants
  • Stacks & QueuesMediumModel answer
    Build a Calculator with Variables, Unary Signs and Parentheses

    Write a linear-time evaluator for integer expressions with variables, precedence, unary signs, parentheses, truncating division and 64-bit error handling.

    Stacks & Queuesparsingrecursive-descentexpression-evaluationtokenization
  • StringsMediumModel answer
    JavaScript Strict vs Loose Equality: Coercion Rules and Pitfalls

    Explain how JavaScript's two equality operators work, how implicit type coercion drives loose equality, where results diverge, and which operator to prefer.

    Stringsjavascripttype-coercionequalitylanguage-fundamentals
  • Trees & GraphsMediumModel answer
    Resolve Variables from Linked Assignment Rules with Cycle Checks

    Evaluate a target variable from a list of assignment strings, growing from simple aliasing to signed sums of variables and integers, then detect circular dependencies safely.

    Trees & Graphsparsingmemoizationdfscycle-detection
  • Data Structure DesignMediumModel answer
    Design a Concurrent Fixed-Size Thread Pool with Task Futures

    Design and implement a fixed-size thread pool with safe task queueing, future result retrieval, exception handling, and graceful or forced shutdown mechanism using basic locks and condition variables.

    Data Structure Designconcurrencythread-pooldesignmultithreading
  • Data Structure DesignMediumModel answer
    Build a Quiet-Period Call Delayer in JavaScript

    Write a higher-order function that postpones a callback until calls have stopped for a given time, preserving this and arguments, and discuss cancel, flush and leading-edge variants.

    Data Structure Designjavascriptclosurestimersdebounce
  • Math & Bit ManipulationEasyModel answer
    Three Cat Owners and a Truth-or-Lie Rule: Find Bob's Count

    Three friends speak under a rule that ties honesty to who owns more cats. Use the statements, parity, divisibility and a sum bound to find Bob's cat count and the triple of counts.

    Math & Bit Manipulationlogic-puzzlecase-analysisdivisibilityparity
  • Data Structure DesignMediumModel answer
    Build a Single-Use Password Reset Token Manager

    Design an in-memory service that issues reset tokens, enforces expiry and a failed-attempt cap, rejects reused passwords, and makes each token usable only once.

    Data Structure Designstate-machinehash-mapauthenticationttl-expiry
  • Data Structure DesignMediumModel answer
    Repair a Faulty LRU Cache and Add Crash-Safe Persistence

    Find and fix the bugs in a broken fixed-capacity LRU cache, then make its acknowledged writes survive a crash using an append-only log, snapshots and atomic file replacement.

    Data Structure Designlru-cachedebuggingwrite-ahead-logcrash-recovery
  • Data Structure DesignMediumModel answer
    Thread-Safe Kitchen: Cook-Once, Pickup-Once Order Pipeline

    Build a thread-safe kitchen where producers place orders, chefs cook them, and customers block until their dish is ready, with no races, deadlocks, or busy-waiting.

    Data Structure Designconcurrencycondition-variableblocking-queuethread-safety
  • Data Structure DesignMediumModel answer
    Time-Travel Key-Value Store with Point-in-Time Snapshots

    Design a hash-map-backed store that records every write with an increasing timestamp, answers reads as of any past moment, and exports a frozen plain-map snapshot.

    Data Structure Designhash-mapbinary-searchversioningsnapshot
  • Heaps, Sorting & SearchMediumModel answer
    Ordering a Hundred Million Decimal Digits in Place

    Order a huge byte array holding only the values 0 to 9 in linear time with constant extra memory, then reason about storage layout, memory bandwidth and expected runtime.

    Heaps, Sorting & Searchcounting-sortin-placememory-bandwidthbytearray
  • StringsMediumModel answer
    Round a Decimal String Without Using Floats

    Round a decimal number given as a string to the nearest integer, then to its last significant digit, using digit-level arithmetic and carry handling instead of floating-point types.

    Stringsstringscarry-propagationroundingparsing
  • Data Structure DesignMediumModel answer
    Streaming Reader for a Page-Based Word Source

    Build a class that wraps a slow, paginated word API and serves exact word counts per call, keeping leftovers between calls and fetching pages lazily.

    Data Structure Designclass-designbufferingpaginationdeque
  • Data Structure DesignMediumModel answer
    Build a Thread-Safe Cart with Pluggable Promotions

    Design an in-memory shopping cart with exact money arithmetic, strategy-based promotions, an itemized receipt, and safe concurrent updates.

    Data Structure Designobject-oriented-designstrategy-patternvalue-objectconcurrency
  • Trees & GraphsEasyModel answer
    Binary Tree Lateral Perspective and Zero-Sum Triplet Extraction

    Solve two fundamental interview tasks: identifying the rightmost nodes of a binary tree by level and finding non-duplicate zero-sum triplets in an un-ordered array.

    Trees & Graphsbinary-treebfstwo-pointerssorting
  • Data Structure DesignMediumModel answer
    Build a Type-Ahead Catalog Lookup with Cancellation and Caching

    Build an accessible type-ahead lookup that delays requests, discards outdated responses, remembers past queries, supports keyboard control, and copes with errors.

    Data Structure Designfrontendreactdebounceabortcontroller
  • Data Structure DesignEasyModel answer
    Dismiss-Then-Navigate: A Browser Notice Helper in Plain JS

    Write a vanilla JavaScript function that shows a message to the user and moves the page to a given address once the message is closed, skipping the move when the address is not a non-empty string.

    Data Structure Designjavascriptdombrowser-apisevent-handling
  • Data Structure DesignMediumModel answer
    Build a Layered In-Memory Work Tracker with Quotas and Deadlines

    Design an in-memory work tracker in four growing stages: CRUD, name and priority queries, per-user limits with timed assignments, then completion and lateness reports.

    Data Structure Designdesignin-memoryhash-mapsorting
  • Data Structure DesignMediumModel answer
    Design a Thread-Safe Log Rotating Sink

    Implement a thread-safe, size-bounded rotating file sink class adhering to Liskov substitution and Python context manager protocols.

    Data Structure Designobject-oriented-designconcurrencyfile-iopython
  • Data Structure DesignHardModel answer
    Build a Scalable Memory-Constrained API Ingestion Pipeline

    Ingest, normalize, filter, and stream-sort paginated API data under memory constraints with exponential backoff and rate limiting.

    Data Structure Designpaginationrate-limitingexternal-sortdata-engineering
  • Math & Bit ManipulationEasyModel answer
    Counting Iterations of a C Loop With an Assignment Condition

    Work out how many times a C for-loop body runs when its condition is an assignment expression rather than a comparison, and explain the final variable values.

    Math & Bit Manipulationc-languagecontrol-flowoperatorsassignment-expression
  • Data Structure DesignMediumModel answer
    Interleaved Dual-Thread Sequencer

    Coordinate two concurrent threads to output consecutive integers from 1 to n in strictly alternating parity order.

    Data Structure Designconcurrencythreadingsynchronizationmutex
  • Data Structure DesignMediumModel answer
    Spot the Slicing and Double-Free Bugs in a C++ Buffer Hierarchy

    Review a C++ class hierarchy that owns a raw heap buffer, explain why passing it by value breaks it, and rewrite it with modern ownership and correct polymorphic dispatch.

    Data Structure Designcppraiirule-of-fiveobject-slicing
  • Data Structure DesignHardModel answer
    Payment Command Parser and Lifecycle State Machine Design

    Design a parser for fixed-arity payment commands and an object-oriented lifecycle state machine, and identify which business rules need clarification before implementation.

    Data Structure Designstate-machineparsingobject-oriented-designvalidation