KatInterview

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

Coding Interview Problems

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

6021
Problems
2229
Auto-graded
15
Topics
272
Added today

Showing 1861–1890 of 2782 results

  • Math & Bit ManipulationMediumModel answer
    Four Labeled Boxes, Only One Label Tells the Truth

    Use a complementary pair of quantified statements to pin down which label is false, then read off the forced conclusion.

    Math & Bit Manipulationlogicpropositional-reasoningquantifiersconstraint-satisfaction
  • Heaps, Sorting & SearchMediumAuto-graded
    K-th Value in a Row-and-Column Sorted Grid

    Tests binary search on value space combined with an O(n) staircase count to efficiently locate the k-th smallest element in a doubly sorted matrix.

    Heaps, Sorting & Searchbinary-searchmatrixheap
  • Data Structure DesignMediumModel answer
    Fix a Broken Round-Robin Load Balancer

    Debug and repair a round-robin router that mis-assigns requests when servers are added, removed, or marked unhealthy, then write tests covering the edge cases.

    Data Structure Designround-robinload-balancingdebuggingconcurrency
  • Data Structure DesignMediumAuto-graded
    Simulate a Bounded Cache That Forgets the Least-Used Entry

    Tests O(1) design of a fixed-size recency-ordered cache: correct eviction order, recency refresh on reads and writes, and update-without-evict semantics.

    Data Structure Designhash-maplinked-listcachedesign
  • Data Structure DesignMediumAuto-graded
    Order State Machine with Transition Validation

    Tests finite state machine implementation with strict transition rules and rejection of invalid state changes.

    Data Structure Designstate-machinevalidationdata-structures
  • StringsMediumAuto-graded
    Sum Two Large Numbers Represented as Digit Strings

    Tests manual digit-by-digit addition with carry propagation on arbitrarily large integers stored as strings.

    Stringsstring-manipulationmathsimulation
  • Dynamic ProgrammingMediumAuto-graded
    Sum of All-One Squares in a Binary Grid

    Tests dynamic programming on 2D grids by computing the total count of square submatrices containing only ones.

    Dynamic Programmingdynamic-programmingmatrices2d-dp
  • Arrays & HashingMediumAuto-graded
    K-th Missing Positive and Sliding-Window Duplicate Events

    Tests order-statistics reasoning for k-th missing positive integers and time-window frequency tracking to detect repeated log events.

    Arrays & Hashingarrayssortingsliding-window
  • Arrays & HashingEasyAuto-graded
    Repeated Values and Longest Two-Distinct Subarray

    Tests hash-based duplicate detection alongside a sliding window that finds the longest subarray containing exactly two distinct integer values.

    Arrays & Hashingsliding-windowhashingtwo-pointers
  • Data Structure DesignMediumAuto-graded
    Variable Registry With Deep Reference Expansion and Cycle Detection

    Tests recursive variable substitution with memoization, cycle detection across direct and indirect references, and clean handling of undefined variable references.

    Data Structure Designstringsrecursionhash-mapcycle-detection
  • Data Structure DesignMediumAuto-graded
    Running Median via Dual-Heap Simulation

    Tests whether a candidate can maintain a live median over an integer stream in O(log n) per insert using two heaps balanced around the midpoint.

    Data Structure Designheapsdata-structure-designonline-algorithms
  • Math & Bit ManipulationEasyAuto-graded
    Four Colleagues in a Row: Recover the Exact Standing Order

    Tests constraint satisfaction and logical deduction by finding the unique left-to-right arrangement of four people from four positional clues.

    Math & Bit Manipulationlogicconstraint-satisfactionbrute-forcepermutations
  • Arrays & HashingMediumAuto-graded
    Leftmost Busiest Slot After Range Increments

    Apply many inclusive range additions over a possibly huge array and return the index holding the largest total, breaking ties toward the smallest index.

    Arrays & Hashingdifference-arrayprefix-suminterval-updatestie-break
  • Data Structure DesignMediumModel answer
    Library Loan Alert Engine: Holds, Checkouts, and Due Reminders

    Design a notification manager for a book lending system that handles hold queues, checkout allocation, and idempotent due-date alerts.

    Data Structure Designheapsimulationidempotencyqueue
  • Trees & GraphsMediumModel answer
    Closest Shared Ancestor for a Group of Org-Chart Nodes

    Build a validated org-chart tree from manager–report pairs and find the deepest node that is an ancestor of every node in a given set.

    Trees & Graphslowest-common-ancestorbinary-liftingtree-traversalinput-validation
  • Heaps, Sorting & SearchMediumAuto-graded
    Select Up to Three Books from Distinct Genres

    Tests greedy optimization with category constraints, hash-map aggregation, and heap-based top-k selection.

    Heaps, Sorting & Searchgreedyhashmapheapoptimization
  • Stacks & QueuesHardAuto-graded
    Simulate a FIFO Queue with Two Stacks

    Tests whether you can emulate first-in-first-out ordering using only two LIFO stacks and explain the amortized cost of each operation.

    Stacks & Queuesstacksqueueamortized-analysis
  • Arrays & HashingMediumAuto-graded
    Assign Minimum Consistent Ranks to Matrix Cells

    Tests greedy assignment of ranks by processing elements in sorted order while maintaining row and column constraints.

    Arrays & Hashingsortinggreedymatrix
  • Stacks & QueuesMediumAuto-graded
    Single-Threaded CPU: Exclusive Runtimes and Stack Snapshot

    Tests stack simulation and interval reasoning by computing per-function exclusive execution time and reconstructing the active call stack at a query timestamp from a sorted event log.

    Stacks & Queuesstacksimulationinterval-reasoning
  • Stacks & QueuesHardModel answer
    Build a Type-Safe C++ Stack from Raw Storage

    Implement a generic, dynamically growing C++ stack using raw memory and placement new, then defend every lifetime, allocation, and call-semantics decision.

    Stacks & QueuesC++memory-managementtemplatesobject-lifetime
  • Arrays & HashingMediumAuto-graded
    Layer-by-Layer Matrix Traversal Without Extra Storage

    Tests boundary-tracking traversal under strict space and immutability constraints, requiring careful handling of single-row and single-column edge cases.

    Arrays & Hashingmatrixtraversalconstant-spaceboundary-tracking
  • Stacks & QueuesMediumAuto-graded
    Bracket Nesting Check and Rotating Cipher

    Tests stack-based bracket validation and modular arithmetic to rotate lowercase letters circularly across the alphabet.

    Stacks & Queuesstacksstringsmodular-arithmetic
  • Stacks & QueuesMediumAuto-graded
    Calculate Arithmetic Expression with Negation and Grouping

    Tests building an operator-precedence parser using stacks to handle binary operations, unary negation, parentheses, and zero-truncating division.

    Stacks & Queuesstacksparsingoperator-precedencestring-processing
  • Arrays & HashingMediumAuto-graded
    Collapse Image Bursts and Rank a Content Stream

    Tests the ability to merge consecutive same-user image posts into gallery items and then apply a stable descending-timestamp sort to the resulting stream.

    Arrays & Hashingsimulationsortingtwo-pointers
  • Trees & GraphsMediumModel answer
    Chain All Words Into One String via Shared Letters

    Given a list of words, merge them into one string by joining where each word's last letter matches the next word's first letter, dropping the duplicate.

    Trees & Graphseulerian-pathgraphstringshierholzer
  • Data Structure DesignMediumModel answer
    Extensible Card Hand Evaluator with Pluggable Rules

    Design and incrementally build a card-hand evaluator that ranks hands, resolves ties deterministically, adds new categories, and applies a swappable discard rule.

    Data Structure Designobject-oriented designextensibilitygame logic
  • Data Structure DesignMediumModel answer
    File Storage Manager with Quota Enforcement

    Build an in-memory file manager that tracks user storage, enforces capacity limits, and evicts largest files when quotas shrink.

    Data Structure Designhash-mapheaplazy-deletionquota-management
  • Arrays & HashingMediumAuto-graded
    Tracking Aligned Prefix Moments in a Permutation Sequence

    Tests the ability to recognize when a running maximum equals the current index in a permutation, using invariant reasoning to avoid simulation.

    Arrays & Hashingpermutationsprefix-conditionrunning-maximuminvariants
  • StringsMediumAuto-graded
    Check Character Mapping Consistency

    Tests whether two strings establish a valid one-to-one character correspondence at each position.

    Stringshash-maptwo-pointersbijection
  • Data Structure DesignMediumModel answer
    Sliding-Window Trending URLs with Deduplication

    Design a data structure that tracks the most-visited URLs over a configurable recent time window, with idempotent inserts and efficient eviction.

    Data Structure Designsliding-windowheaphash-mapstreaming