KatInterview

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

Coding Interview Problems

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

5980
Problems
2215
Auto-graded
15
Topics
272
Added today

Showing 211–240 of 2765 results

  • Dynamic ProgrammingMediumAuto-graded
    Best Final Score from Affine Card Purchases Under a Budget

    Choose a budget-limited subset of cards and an order to maximize a score updated by an affine rule, testing subset and ordering search and exchange-argument reasoning.

    Dynamic Programmingsubset-searchpermutationsexchange-argumentknapsack
  • Trees & GraphsMediumModel answer
    Identify Node Value Present Across Most Depth Levels

    Find the binary tree node value that appears across the highest number of unique depth levels.

    Trees & Graphstrees-graphsbreadth-first-searchhash-table
  • Heaps, Sorting & SearchMediumAuto-graded
    Truncate and Renormalize a Next-Token Distribution

    Sort a probability list with deterministic tie-breaking, then build two truncated, renormalized versions: fixed-size top-k and cumulative-mass top-p.

    Heaps, Sorting & Searchsortingprefix-sumprobabilityfloating-point
  • Heaps, Sorting & SearchMediumAuto-graded
    Locate a Value in a Cyclically Shifted Ascending List

    Search a cyclically shifted strictly increasing list of distinct integers for a value in O(log n), returning its index or -1, including unshifted and single-element cases.

    Heaps, Sorting & Searchbinary-searcharraysrotated-arraydivide-and-conquer
  • Stacks & QueuesMediumAuto-graded
    Infer Execution Events from Call Stack Snapshots

    Reconstruct chronological function START and END lifecycle events by evaluating structural differences across consecutive call stack snapshots.

    Stacks & Queuesstacks-queuesarraysstrings
  • Arrays & HashingEasyAuto-graded
    Group Identical Files by Content from an In-Memory Listing

    Group file entries that have identical byte content, using content length as a cheap first filter, and return only groups of two or more paths in a specified order.

    Arrays & Hashinghashinggroupingstringssimulation
  • Arrays & HashingMediumAuto-graded
    Tally Contiguous Segments Matching a Goal Total

    Count contiguous non-empty segments of an integer array whose sum equals a goal, using running totals and a frequency map to handle negatives and zeros in linear time.

    Arrays & Hashingprefix-sumhash-mapsubarraycounting
  • Greedy & IntervalsMediumAuto-graded
    Max Gains from Single and Multi-Trade Asset Strategies

    Calculate maximum achievable gain for an asset sequence under single-trade and unlimited-trade restrictions.

    Greedy & Intervalsarraysgreedydynamic-programming
  • Math & Bit ManipulationEasyAuto-graded
    Spread of a Number List: Population Variance

    Implement population variance on a list of numbers without external libraries, handling empty and single-element inputs and choosing a numerically sound approach.

    Math & Bit Manipulationvariancestatisticsfloating-pointarrays
  • Trees & GraphsEasyAuto-graded
    Distance Map to the Closest Exit in a Maze Grid

    Compute, for every cell of a grid with walls and exits, the fewest steps to the nearest exit, marking walls and cut-off cells as -1, using multi-source BFS.

    Trees & Graphsbfsgridmulti-source-bfsshortest-path
  • Arrays & HashingEasyAuto-graded
    Simulate Key-Value Operations

    Process a series of insertion, update, and deletion instructions on a key-value store and return the final contents ordered by key.

    Arrays & Hashingarraysstringshash-table
  • Heaps, Sorting & SearchMediumAuto-graded
    Stable Divide-and-Conquer Sort of an Integer List

    Sort a list of integers in ascending order without mutating the input, using a divide-and-conquer merge approach that guarantees O(n log n) time and linear auxiliary space.

    Heaps, Sorting & Searchsortingdivide-and-conquermerge-sortstability
  • Heaps, Sorting & SearchMediumAuto-graded
    Rank Selection Plus Longest Leave-Assisted Break

    Combines selecting the element at a 0-indexed rank in descending order with a sliding window finding the longest stretch containing at most a given number of workdays.

    Heaps, Sorting & Searchheapsliding-windowtwo-pointersorder-statistics
  • Heaps, Sorting & SearchMediumAuto-graded
    Identify Unique Zero-Sum Triples

    Find all distinct combinations of three elements in an integer sequence that sum to zero using two pointers and duplicate handling.

    Heaps, Sorting & Searcharraystwo-pointerssorting
  • StringsMediumAuto-graded
    Words Spelled by a Finger Trace Across Keys

    Find all dictionary words that fit a key trace as a start- and end-anchored subsequence where letters may reuse a key, using a next-occurrence table to match many words efficiently.

    Stringsstringssubsequencegreedyprecomputation
  • Trees & GraphsHardModel answer
    Region-Splitting Tree and Multi-Word Grid Search

    Compress a square character grid into a four-way region tree, then locate a batch of words in the grid by walking neighbors in eight directions without reusing cells.

    Trees & Graphsquadtreetriebacktrackingdivide-and-conquer
  • StringsMediumAuto-graded
    Resolve Nested %NAME% Placeholders with Cycle Detection

    Expand %NAME% placeholders whose values may reference other placeholders, handling %% escapes, missing names, and circular references.

    Stringsparsingdfsmemoizationcycle-detection
  • Dynamic ProgrammingMediumAuto-graded
    Counting Sorted Sequences With Prescribed Digit Sums

    Count non-decreasing sequences of integers in [0, 5000] whose i-th element has a given digit sum, using DP over candidate values with prefix sums, modulo 1,000,000,007.

    Dynamic Programmingdynamic-programmingprefix-sumstwo-pointerscounting
  • Greedy & IntervalsMediumModel answer
    Staffing Timeline from Overlapping Work Shifts

    Turn a list of overlapping employee shifts into contiguous time segments, each listing who is on duty, with empty segments marking gaps in coverage.

    Greedy & Intervalssweep-lineintervalshash-mapsorting
  • Greedy & IntervalsMediumAuto-graded
    Estimate Percentile from Histogram Buckets

    Linearly interpolate a percentile value across histogram buckets assuming uniform distribution within each interval.

    Greedy & Intervalsmathintervalshistogrampercentile
  • StringsMediumModel answer
    String Internals, Move Costs, and Threads vs Async Tasks

    Describe how a string is laid out in memory, what copying and moving really cost, what a Rust move does, and how OS threads differ from async coroutines.

    Stringsstringsmemory-managementmove-semanticsrust
  • Data Structure DesignMediumAuto-graded
    Replay a Sequence of Recency-Evicting Cache Commands

    Simulate a fixed-capacity cache that evicts the least recently used entry, replaying a list of get/put commands and returning each command's result.

    Data Structure Designlru-cachehash-maplinked-listsimulation
  • Dynamic ProgrammingHardAuto-graded
    Fewest Cabinets for Two-Resource Jobs

    Group jobs with two resource demands into the fewest identical cabinets, using exact search with symmetry breaking and pruning (2D vector bin packing).

    Dynamic Programmingbin-packingbacktrackingbitmaskcombinatorial-optimization
  • Math & Bit ManipulationMediumAuto-graded
    Smallest Palindrome Above a Given Number

    Find the smallest palindromic integer strictly larger than a non-negative integer, using the left half of the digits and carry handling, including the all-9s case.

    Math & Bit Manipulationpalindromedigitsmathcarry
  • Greedy & IntervalsMediumAuto-graded
    Sentinels on a Road: Best Covered Value With Single Left Steps

    Maximize the total value of covered towns on a line when each sentinel may step one town left at most once into an empty town, by finding which town each run of sentinels leaves uncovered.

    Greedy & Intervalsgreedystringsarrayssegments
  • Math & Bit ManipulationEasyAuto-graded
    Total of Numbers Sharing a Factor of 3, 5, or 7

    Compute the sum of integers from 1 to n divisible by at least one of 3, 5, or 7, counting each integer once, which tests overlap handling and inclusive bounds.

    Math & Bit Manipulationmathinclusion-exclusioniterationdivisibility
  • Arrays & HashingMediumAuto-graded
    Closest Response Times: List the Tightest Increasing Pairs

    Find the smallest absolute gap between any two readings, then list every strictly increasing pair achieving it, handling duplicates correctly. Tests sorting and adjacent-gap reasoning.

    Arrays & Hashingsortingarraysadjacent-differenceedge-cases
  • Data Structure DesignMediumModel answer
    Upgrade a Streaming Log Filter to Multi-Code and JSON Output

    Refactor a small Python log-counting script so it filters on several status codes, optionally writes JSON, streams multi-gigabyte files in constant memory, and stays unit-testable.

    Data Structure Designpythonrefactoringstreamingcli
  • Data Structure DesignMediumAuto-graded
    Batch Simulator for a TTL-Aware Name Lookup Service with Aliases

    Simulate a batch of record insertions and lookups with normalized names, TTL expiry, alias-chain following, cycle and hop-limit detection, and A/alias exclusivity.

    Data Structure Designhash-mapsimulationdesignstring-normalization
  • Trees & GraphsMediumAuto-graded
    Fastest Route Time Through a One-Way Street Network

    Find the minimum total cost between two nodes of a directed graph with non-negative edge weights, returning -1 if no route exists. Tests shortest-path reasoning with a priority queue.

    Trees & Graphsdijkstrashortest-pathgraphheap