KatInterview

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

Coding Interview Problems

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

5987
Problems
2219
Auto-graded
15
Topics
270
Added today

Showing 331–360 of 651 results

  • Data Structure DesignMediumModel answer
    Fast Machine Selection for a Memory-Aware Table Placer

    Redesign a slow in-memory placer so it finds a machine with enough free RAM, resizes tables, and moves them quickly, while justifying a placement policy.

    Data Structure Designdata-structure-designbisectbest-fitscheduling
  • Greedy & IntervalsMediumModel answer
    Split Overlapping Support Windows by Who Is Covering

    Break a set of possibly overlapping staffed time windows into disjoint half-open segments, each labeled with the sorted set of people covering it, dropping gaps and merging equal neighbors.

    Greedy & Intervalssweep-lineintervalshash-mapsorting
  • Data Structure DesignMediumModel answer
    Timeline Lookup Store and Shared-Friend Suggestions

    Build a store that returns the latest value at or before a query time, then suggest new connections to a user based on having at least two friends in common.

    Data Structure Designbinary-searchhash-mapgraphdesign
  • Math & Bit ManipulationMediumModel answer
    Back-Calculating a Kayak Trip's Start Time from River Speeds

    Two paddlers' first-day upstream and downstream legs fix their paddling speed. Use it to find when they must leave on day two to reach a point 23 miles upstream by 16:00.

    Math & Bit Manipulationword-problemrelative-velocityrate-time-distancealgebra
  • StringsMediumModel answer
    Three Compiler Defects in a Mini Template Engine: Debug and Test

    Diagnose three failures in a small Python template-to-source compiler: a lost ternary branch, a directory returned as a template, and a comment-only loop body, then fix each and add a regression test.

    Stringsdebuggingcode-generationastregression-testing
  • Heaps, Sorting & SearchMediumModel answer
    Batched Notification Sender with Cooldown-Aware Retries

    Push messages through a provider that accepts at most 5 per call, and retry each failure only after its own cooldown expires, with an attempt cap and no busy-waiting.

    Heaps, Sorting & Searchbatchingpriority-queueretry-schedulingmin-heap
  • Data Structure DesignMediumModel answer
    Audit a Flawed Proximity-Search Module in Python

    Review a small Python module for finding and labeling nearby places, spotting correctness, speed and design problems, then propose and justify concrete refactors.

    Data Structure Designcode-reviewpythongeospatialhaversine
  • Trees & GraphsMediumModel answer
    Concurrent Site Crawler with Fault-Tolerant Fetching

    Build a crawler that explores every page reachable from a seed URL using a slow, flaky link API, evolving from a sequential traversal to a thread pool with bounded, backoff-driven retries.

    Trees & Graphsweb-crawlerconcurrencybfsretries
  • Heaps, Sorting & SearchMediumModel answer
    Cost of Core Data Structure Ops and When Threads Hurt

    Give worst-case Big-O for four common array, hash table and heap operations, then explain why adding threads does not always speed a program up, with concrete counterexamples.

    Heaps, Sorting & Searchbig-ohash-tableheapmultithreading
  • Heaps, Sorting & SearchMediumModel answer
    Fixed-Width Window Totals and Rolling Median Over a Stream

    Find the best sum over any run of k adjacent numbers, then track the median of the latest k values in a live stream, discussing data structures, parallelism and trade-offs.

    Heaps, Sorting & Searchsliding-windowtwo-heapsmedianlazy-deletion
  • Data Structure DesignMediumModel answer
    Weighted Random Picker for Unbounded Integer Scores

    Build a picker that returns an item with probability proportional to its weight, even when weights and their total exceed 32-bit or 64-bit limits, and discuss precision and memory trade-offs.

    Data Structure Designrandomized-algorithmsprefix-sumbinary-searchalias-method
  • Data Structure DesignMediumModel answer
    Design a Pluggable Payroll Cost Estimator

    Design the types and API that compute an employee's full cost from salary, tax, benefits, and a signed location adjustment, with exact money math, explicit missing-rule handling, and versioned rules.

    Data Structure Designobject-modelingapi-designmoney-handlingconfiguration-versioning
  • Data Structure DesignHardModel answer
    Steady-Cadence Frame Player with Bounded Decode Buffer

    Build a thread-safe player where a decoder thread fills a bounded buffer and a render thread emits frames at a fixed rate on a monotonic clock, with clean pause, stop and underrun handling.

    Data Structure Designconcurrencyproducer-consumerthreadingscheduling
  • Data Structure DesignHardModel answer
    Build a Accessible, Controllable Select Menu in React

    Design and implement a reusable select-style menu in React with controlled and uncontrolled state, keyboard support, ARIA semantics, and a plan for production hardening.

    Data Structure Designreactfrontendaccessibilitycomponent-design
  • Data Structure DesignHardModel answer
    Live Portfolio Valuation Across Tag-Filtered Books

    Design a class that maintains mark-to-market profit for many tag-filtered trade groups while trades and price ticks stream in, without rescanning trade history on each update.

    Data Structure Designdesignhashingincremental-updatelazy-evaluation
  • Trees & GraphsMediumModel answer
    Crawl One Site: Sequential Traversal, Then a Parallel Version

    Collect every page reachable from a seed URL on the same host, ignoring URL fragments and fetching each page once, first with one thread and then with safe concurrency.

    Trees & Graphsweb-crawlerbfsconcurrencythread-safety
  • Data Structure DesignMediumModel answer
    Minesweeper Solver: Deduction Rules and Mine Probabilities

    Design a Minesweeper bot that derives certain mines and safe cells from overlapping numbers, estimates mine probabilities when it must guess, and is evaluated by win rate.

    Data Structure Designminesweeperconstraint-satisfactionprobabilitybacktracking
  • Trees & GraphsMediumModel answer
    Print a Reporting Hierarchy and List Two-Level-Down Pairs

    Turn manager rows into a tree, infer the root, print it with depth-based dot indentation, or list every (manager, employee) pair exactly two levels apart.

    Trees & Graphstreepreorderiterative-dfshash-map
  • Linked ListsMediumModel answer
    Sequence Storage Trade-offs: Contiguous Arrays vs Pointer Chains

    Contrast contiguous arrays, linked lists, and unrolled lists for indexed reads, inserts, growth, traversal speed, and cache behavior, and say when each one wins.

    Linked Listsarrayslinked-listsunrolled-linked-listcache-locality
  • Data Structure DesignMediumModel answer
    Singleton, Factory Method and Strategy: Code and Compare in Java

    Write Java versions of a lazy thread-safe Singleton, a Factory Method and a Strategy, weigh them against each other, then refactor a Singleton dependency to use injection.

    Data Structure Designdesign-patternsjavasingletonfactory-method
  • Data Structure DesignMediumModel answer
    In-Memory Ledger with Ranking by Total Money Sent

    Build an in-memory ledger supporting account creation, deposits and transfers, plus a query returning the top n senders by cumulative outgoing amount with deterministic tie-breaking.

    Data Structure Designdata-structure-designhash-mapheaptop-k
  • StringsMediumModel answer
    Repair a Rewards Calculator: Three Red Tests in a Java Service

    Diagnose and fix three failing JUnit tests in a Java rewards service by touching at most three files, then explain how to keep similar bugs from coming back.

    Stringsjavadebuggingunit-testingjunit
  • Stacks & QueuesMediumModel answer
    Predicting Output Order with the Browser Event Loop

    Work out the print order of a short script mixing timers, promises and microtasks, then explain how the browser event loop schedules each kind of task.

    Stacks & Queuesjavascriptevent-loopasyncmicrotasks
  • Data Structure DesignHardModel answer
    Crash-Safe Job Dispatcher with Lease Timeouts and Dependency Graphs

    Build an in-memory job dispatcher where workers hold timed leases, stale workers are fenced off, jobs form a dependency DAG, and you justify the delivery guarantees.

    Data Structure Designleasesfencing-tokensdagtopological-sort
  • Arrays & HashingMediumModel answer
    Randomly Fill Ad Slots Under Per-User View Caps

    Randomly assign eligible ads to page positions for one user, respecting per-user display caps, avoiding repeats when possible, and returning the updated view counts.

    Arrays & Hashingrandomizationhash-mapshuffleresource-allocation
  • Greedy & IntervalsHardModel answer
    Payroll From an Event Log With Surge Windows

    Turn a day's delivery events into total driver pay, then add doubled-rate surge windows by splitting intervals at boundaries, and decide how to handle messy or inconsistent logs.

    Greedy & Intervalsintervalsevent-processinghashingsorting
  • Data Structure DesignMediumModel answer
    Weighted Random Picker with Live Weight Updates

    Design a sampler that picks an index in proportion to its weight, supports weight changes, draws several distinct items, and can be seeded and tested statistically.

    Data Structure Designweighted-samplingfenwick-treeprefix-sumsbinary-search
  • Trees & GraphsMediumModel answer
    Thread-Pooled Link Crawler with Depth Limit and Dedup

    Implement a thread-safe crawler that explores links from a seed page to a given depth, never fetches a URL twice, and caps the number of simultaneous fetches.

    Trees & Graphsconcurrencybfsthread-poolgraph-traversal
  • Trees & GraphsMediumModel answer
    Round-Trip Text Encoding for Ordered Trees with Any Number of Children

    Define a text format for ordered trees with arbitrary branching, then write an encoder and decoder that rebuild the exact same values, structure and child order in linear time.

    Trees & Graphstreeserializationn-ary-treeiterative-dfs
  • Data Structure DesignHardModel answer
    Build an Exact Usage Ledger for Chunked LLM Responses

    Design a billing ledger that merges streamed token deltas and one-shot totals, validates events strictly, and keeps all money as integer nano-USD to avoid floating-point drift.

    Data Structure Designdesign-dshash-mapvalidationstate-machine