KatInterview

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

Coding Interview Problems

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

5997
Problems
2221
Auto-graded
15
Topics
270
Added today

Showing 481–510 of 2773 results

  • Trees & GraphsMediumAuto-graded
    Balanced BST Level-Order Output from a Sorted Sequence

    Build a height-balanced BST from a sorted list using a fixed middle-element rule, then serialize it level by level with null placeholders.

    Trees & Graphsbinary-search-treedivide-and-conquerrecursionlevel-order-traversal
  • Data Structure DesignMediumAuto-graded
    Shift Ledger: Rates, Promotions and Bonus Windows

    Simulate a command stream for a shift ledger with deferred pay-rate changes, merged global bonus windows and a ranking of employees by hours worked.

    Data Structure Designdesignsimulationinterval-mergingsorting
  • Stacks & QueuesMediumModel answer
    Build a Tiny Expression Language Interpreter in Three Stages

    Implement a lexer, recursive-descent parser and evaluator for a small integer language with variables, unary minus, precedence, truncating division and print.

    Stacks & Queuesparsinginterpreterrecursive-descentast
  • Arrays & HashingMediumAuto-graded
    Clockwise Grid Walk Around Obstacles and Visited Cells

    Simulate a clockwise inward walk over a grid with obstacle cells, turning on edges, obstacles and visited cells, and stopping when every direction is closed.

    Arrays & Hashingmatrixsimulationspiralgrid
  • Stacks & QueuesMediumAuto-graded
    Parenthesized Integer Calculator with Unary Negation

    Evaluate an integer expression with +, -, *, /, parentheses and unary minus in one iterative pass, using precedence rules and division that truncates toward zero.

    Stacks & Queuesstackparsingexpression-evaluationshunting-yard
  • Trees & GraphsMediumAuto-graded
    Locked Gates Grid: Fewest Steps With Collected Keys

    Find the fewest moves through a grid where lowercase cells give keys and uppercase cells are gates, using BFS over position plus the set of collected keys.

    Trees & Graphsbfsgridstate-space-searchkeys-and-doors
  • Trees & GraphsMediumAuto-graded
    Reconstruct Hierarchical Execution Trees from Trace Records

    Reassemble an unordered collection of trace span objects into a forest of child-linked execution trees sorted chronologically.

    Trees & Graphstreeshash-tablesortinggraph
  • Data Structure DesignMediumAuto-graded
    Resumable Batch Reader for a Linked Page Feed

    Simulate a stateful reader that serves batches of N items in order from a chained page feed, buffering surplus items and handling empty pages, loops and the end of the feed.

    Data Structure Designdesignpaginationbufferingsimulation
  • StringsMediumAuto-graded
    Tally Slices Whose Letters Are All Different

    Count every contiguous slice of a lowercase string in which no letter appears twice, using a linear-time sliding window.

    Stringssliding-windowtwo-pointersstringscounting
  • Data Structure DesignMediumAuto-graded
    Replay Bounded Cache Commands with Recency Eviction

    Simulate a fixed-capacity key-value store that evicts its stalest entry, replaying a command log in O(1) per step using a hash map and recency ordering.

    Data Structure Designlru-cachehash-mapdoubly-linked-listsimulation
  • Data Structure DesignMediumAuto-graded
    Replay a Recency-Evicting Cache from a Command Log

    Simulate a fixed-size cache that evicts the least recently used entry, by replaying text commands and collecting the answers to lookups in order.

    Data Structure Designlru-cachehash-mapordered-dictsimulation
  • Data Structure DesignMediumModel answer
    Design a Safe, Idempotent Auto-Approval Engine for Order Refunds

    Design and code a refund decision engine that applies pluggable rules, never refunds more than was paid, and handles retried or concurrent requests without paying twice.

    Data Structure Designdomain-modelingidempotencyrules-enginemoney-handling
  • Data Structure DesignMediumAuto-graded
    Replay Operations on a Bounded Recency-Evicting Store

    Simulate a fixed-size key-value store that evicts the stalest entry, replaying a list of get/put commands and returning each command's result.

    Data Structure Designhash-maplinked-listordered-dictsimulation
  • Trees & GraphsEasyAuto-graded
    Group Hierarchy Members by Depth Level

    Construct an adjacency graph from reporting links and perform a level-order traversal to group node IDs by depth.

    Trees & Graphstrees-graphsbfshash-map
  • Greedy & IntervalsMediumAuto-graded
    Minimum Time Slots for Cooldown-Constrained Jobs

    Compute the shortest timeline needed to run labeled jobs when equal labels must be separated by a cooldown, using frequency counting and a greedy frame argument.

    Greedy & Intervalsgreedycountingschedulingmath
  • Math & Bit ManipulationMediumAuto-graded
    Two-Segment Rider Model: Weekly Activity, Posterior, Forecast

    Compute three probabilities from a two-group mixture model: at-least-one-success over n days, a Bayesian posterior after all-success streaks, and a posterior predictive forecast.

    Math & Bit Manipulationprobabilitybayesmixture-modelcomplement-rule
  • Trees & GraphsMediumAuto-graded
    Best Plot After Reclaiming a Single Water Tile

    Find the largest connected land region achievable by turning at most one water cell into land, which tests component labeling and merging neighbors without double counting.

    Trees & Graphsgridflood-fillconnected-componentsdfs
  • Trees & GraphsMediumAuto-graded
    Two Teams With Rival Pairs Kept Apart

    Decide whether a set of people can be placed into two teams so that no rival pair shares a team, which tests graph 2-coloring across possibly disconnected components.

    Trees & Graphsgraphbipartitebfscoloring
  • Data Structure DesignMediumAuto-graded
    Simulate a Cursor Editor with Sticky-Column Vertical Moves

    Replay a log of editor commands (type, backspace, move in four directions, render) on a single-cursor multi-line buffer, with a column that persists across vertical moves.

    Data Structure Designsimulationdesigncursorstrings
  • Data Structure DesignMediumAuto-graded
    Versioned Key-Field Store with Expiry and Time Travel

    Simulate a timestamped two-level store with expiring values, conditional updates, sorted prefix scans and historical lookups, driven by a batch of operations.

    Data Structure Designdesignhash-mapbinary-searchttl
  • Trees & GraphsMediumAuto-graded
    Render a Nested Folder Structure as Indented Lines

    Traverse a nested dictionary tree in pre-order, tracking depth to build indented lines with a fixed marker, preserving the given child order.

    Trees & Graphstree-traversaldfsstackstrings
  • Data Structure DesignHardModel answer
    Design a Tree-Based Storage Simulator with Auto-Renaming

    Build an in-memory file store that auto-creates parent folders, renames clashing files with the lowest free numeric tag, and lists folder contents in ASCII order.

    Data Structure Designdesigntreehash-setstrings
  • Math & Bit ManipulationHardAuto-graded
    Count Substrings Rearrangeable into Palindromes

    Given a list of strings, count the number of contiguous substrings in each string whose characters can be permuted to form a valid palindrome.

    Math & Bit Manipulationbit-manipulationhash-tablestringsprefix-sum
  • StringsMediumAuto-graded
    Rolling Up Page Views Through Hostname Suffixes

    Aggregate per-host view counts so every host and each of its parent suffixes gets the total of itself and all hosts beneath it, using suffix enumeration and a hash map.

    Stringshash-mapstringsparsingsuffix-enumeration
  • Arrays & HashingEasyAuto-graded
    Determine Highest Single Transaction Stock Profit

    Find the maximum gain possible from buying and selling a stock once, given a sequence of daily values.

    Arrays & Hashingarraysgreedydynamic-programming
  • Heaps, Sorting & SearchMediumAuto-graded
    Smallest Conveyor Load Limit for Sequential Parcels

    Find the minimum per-day load limit that moves an ordered list of parcels in at most a given number of days, using binary search on the answer with a greedy feasibility check.

    Heaps, Sorting & Searchbinary-searchgreedysearch-on-answerarrays
  • Data Structure DesignMediumModel answer
    Pluggable Payment Dispatch with Spring Bean Maps

    Design an extensible payment dispatcher in Spring where a Map of strategy beans is injected automatically and new payment methods need no changes to the service.

    Data Structure Designjavaspringstrategy-patternsolid
  • StringsEasyAuto-graded
    Encode Keypad Multi-Tap Strokes

    Simulate telephone keypad multi-tap text encoding while inserting pause delimiters for consecutive letters on the same digit key.

    Stringsstringshash-tablesimulation
  • Arrays & HashingMediumAuto-graded
    Subarrays Whose Matching-Element Count Hits a Residue

    Count subarrays where the number of elements congruent to a residue, taken modulo the same base, equals that residue, using prefix remainders and a frequency table.

    Arrays & Hashingprefix-sumhash-mapmodular-arithmeticsubarrays
  • StringsMediumAuto-graded
    Validate a Plain Signed Decimal Literal

    Check whether a string is a well-formed plain decimal literal (optional sign, digits, optional fraction) by turning a small grammar into a careful single-pass validator.

    Stringsstringsparsingvalidationedge-cases