KatInterview

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

Coding Interview Problems

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

5985
Problems
2218
Auto-graded
15
Topics
271
Added today

Showing 391–420 of 651 results

  • Data Structure DesignMediumModel answer
    Concurrent Queue with Bounded Capacity and Graceful Shutdown

    Implement a thread-safe FIFO queue with fixed capacity, blocking operations, timeout support, and coordinated shutdown behavior.

    Data Structure Designconcurrencythreadingsynchronizationmonitor-pattern
  • Arrays & HashingMediumModel answer
    Walk Through Your Subarray Solution and Its Trade-offs

    Given a solution to a subarray-sum problem, explain your approach, prove it correct, analyze complexity, and compare it to at least two alternatives.

    Arrays & Hashingprefix-sumhash-mapcomplexity-analysiscommunication
  • Data Structure DesignMediumModel answer
    One-Edit Word Lookup and Vertical Tree Traversal

    Design a data structure for single-character substitution queries, then output a binary tree's node values sorted by column, row, and left-to-right order.

    Data Structure Designhashingtriebinary-treebfs
  • Trees & GraphsMediumModel answer
    Minimum Spread Time for Contamination in a Grid

    Find how many steps a contamination spreads from multiple sources through a grid, or determine if some cells remain permanently unaffected.

    Trees & GraphsBFSmulti-source BFSgrid traversalshortest path
  • Data Structure DesignHardModel answer
    Live Spreadsheet with Eager Caching and Cycle Guards

    Build a spreadsheet engine where every write pre-computes all downstream values so reads are O(1) cache lookups, and circular definitions are rejected atomically.

    Data Structure Designgraphstopological-sortcycle-detectiondependency-tracking
  • StringsMediumModel answer
    Config-Driven CSV Validator with Name Overlap Check

    Write a configurable validator that flags missing fields, length violations, banned words, and low name-word overlap across CSV vendor rows.

    Stringscsv-parsingvalidationregextext-normalization
  • Data Structure DesignMediumModel answer
    Build an In-Memory Key-Value Store with Savepoints

    Design a transactional key-value store supporting nested transactions, named savepoints, and full rollback using an undo-log approach.

    Data Structure Designtransactionsundo-logkey-value-storenested-transactions
  • Math & Bit ManipulationMediumModel answer
    Square Root by Newton's Method and Odd/Even Index Partitioning

    Implement sqrt from scratch with range reduction plus Newton's method, and rearrange an array in O(1) space so even-positioned values all beat odd-positioned ones.

    Math & Bit Manipulationnewton-methodquickselectin-place-partitionnumerical-precision
  • Data Structure DesignMediumModel answer
    Build a FIFO Queue: Compare Linked List, Array, and Ring Buffer

    Implement a queue with enqueue, dequeue, peek, and isEmpty. Compare linked list, dynamic array, and circular buffer approaches.

    Data Structure Designqueuedata-structurescomplexity-analysismemory-management
  • Trees & GraphsMediumModel answer
    Trace a Target String Through a Character Grid

    Decide whether a word can be spelled by a non-repeating, four-directional path of adjacent cells in a character matrix, with pruning and complexity analysis.

    Trees & Graphsbacktrackingdepth-first-searchgridpruning
  • Dynamic ProgrammingMediumModel answer
    Stock Trading Profit with Transaction Limits and Fees

    Maximize stock trading profit given a cap on total transactions and a per-sale fee, using a unified DP state machine.

    Dynamic Programmingdynamic-programmingstate-machinegreedy
  • Data Structure DesignMediumModel answer
    Build a Thread-Safe Token Bucket Rate Limiter

    Implement a token bucket that refills lazily on each admission attempt, handles concurrent callers safely, and supports both non-blocking and timeout-bounded acquisition.

    Data Structure Designconcurrencyrate-limitingsynchronization
  • StringsMediumModel answer
    Build a POSIX Shell Script with Validation and Structured Output

    Write a strict POSIX sh script that validates arguments, reads a file, extracts a license string, and prints a formatted timestamped line.

    StringsshellPOSIXCLIerror-handling
  • Trees & GraphsMediumModel answer
    Collapsible Nested Menu with ARIA Support

    Design and code a React component that displays hierarchical data with interactive expand/collapse behavior and full keyboard accessibility.

    Trees & Graphsreactrecursionaccessibilitystate-management
  • Data Structure DesignMediumModel answer
    Concurrent Data Structures and Calendar Scheduling

    Build thread-safe request throttling, search from scratch, frequency-ranked retrieval, and multi-calendar availability finder.

    Data Structure Designconcurrencydata-structuresalgorithmsscheduling
  • StringsMediumModel answer
    Find Optimal Single Digit Exchange to Maximize Value

    Swap at most two digits in a non-negative integer to achieve the largest possible result.

    Stringsgreedystring-manipulationoptimization
  • Data Structure DesignMediumModel answer
    Build a Multi-Key Task Queue with Ordering and Concurrency Control

    Create a thread-safe task scheduler that runs tasks sequentially per key while respecting a global worker limit and capacity bound.

    Data Structure Designconcurrencythreadingqueuesynchronization
  • Trees & GraphsMediumModel answer
    Threaded Comment Feed: Filtering, Nesting, and Persistent Sort

    Transform a flat array of comments into a sorted, nested, filterable tree while persisting the user's sort preference across sessions.

    Trees & Graphstree-constructiondfslocalStoragefrontend-data
  • Data Structure DesignMediumModel answer
    Multiset with O(1) Insert, Delete, and Uniform Random Sampling

    Build a collection supporting duplicates with constant-time insertion, deletion, and uniform random selection from all stored occurrences.

    Data Structure Designdata-structureshash-tablesrandomization
  • Data Structure DesignMediumModel answer
    Two-Tier API Rate Limiter with a Sliding Window

    Design a thread-safe rate limiter that enforces both a per-endpoint quota and a shared global quota using a rolling time window.

    Data Structure Designrate-limitingconcurrencysliding-windowthread-safety
  • Data Structure DesignMediumModel answer
    Build a Reference-Counted Shared Ownership Pointer in C++

    Implement a thread-safe shared ownership smart pointer class template from scratch, covering copy/move semantics, atomic reference counting, and correct destruction.

    Data Structure Designc++memory-managementconcurrency
  • Data Structure DesignMediumModel answer
    Dynamic Hierarchy Manager with Timestamp Ordering

    Build a system that processes timestamped parent-child updates arriving in any order, maintains a valid tree structure, and prevents cycles.

    Data Structure Designtreesgraphsstate-managementcycle-detection
  • Trees & GraphsMediumModel answer
    Content-Based Duplicate File Detector

    Recursively scan a directory tree, group files by size then content hash, and return every set of two or more paths that hold identical bytes.

    Trees & Graphshashingfile-systemtraversaldeduplication
  • Data Structure DesignMediumModel answer
    Design a Five-Card Hand Evaluator with Partial Hand Completion

    Model poker-style five-card hands with an abstract type hierarchy, compare two hands by strength and tie-break, then find the strongest and weakest completions of a partial hand.

    Data Structure Designobject-oriented designclassificationcombinatoricscomplexity analysis
  • Data Structure DesignMediumModel answer
    Concurrent Task Execution with Type-Level Exclusion

    Build a synchronization mechanism allowing tasks of the same type to run together while blocking tasks of different types from overlapping.

    Data Structure Designconcurrencythreadingsynchronization
  • Data Structure DesignMediumModel answer
    Defensive Coding: Validate and Harden a Snake Game

    Design an input-validation strategy, error-handling policy, and test suite to protect a Snake game implementation from every class of bad input.

    Data Structure Designvalidationerror-handlingtestingsnake-game
  • Trees & GraphsMediumModel answer
    Find the Longest Path in an Undirected Tree

    Given a tree as an adjacency list, return the sequence of nodes forming its diameter — the longest simple path between any two nodes.

    Trees & GraphsBFSDFStree diameterpath reconstruction
  • Heaps, Sorting & SearchHardModel answer
    Rolling Window Median Bounds + Binary Array Tiling

    Find the max and min sliding-window medians in O(n log k), then partition a binary array into even uniform segments with minimum flips.

    Heaps, Sorting & Searchsliding windowheapdynamic programmingbinary array
  • Arrays & HashingMediumModel answer
    Layered Invoice Processor with Discounts, Tax, and FX

    Build a multi-part order cost engine that handles input validation, per-item discounts, order-level tax, multi-currency conversion, and banker's rounding.

    Arrays & Hashingdata-processingdecimal-arithmeticinput-validationsorting
  • Data Structure DesignHardModel answer
    Build a Subscription Pattern Recognition Engine

    Create a system that discovers recurring billing patterns in transaction data, handling merchant name variations, timing drift, and price changes.

    Data Structure Designpattern-recognitiondata-processingheuristics