KatInterview

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

Coding Interview Problems

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

6016
Problems
2229
Auto-graded
15
Topics
274
Added today

Showing 1951–1980 of 2782 results

  • Data Structure DesignHardModel answer
    Greedy Text Tokenizer with Vocabulary Trie

    Build a tokenizer that greedily matches the longest vocabulary token at each position, handling unknown characters with optional span merging.

    Data Structure Designtriestring-matchingtokenizationgreedy-algorithms
  • Trees & GraphsMediumAuto-graded
    Schedule Courses Given Prerequisites

    Tests directed graph modeling, cycle detection, and topological ordering using Kahn's algorithm or DFS.

    Trees & Graphstopological-sortgraphkahn-algorithmcycle-detection
  • Math & Bit ManipulationMediumAuto-graded
    Reroll Game Expected Value and Break-Even Cost

    Tests probability recursion, expected value with random stopping times, and cost-benefit analysis in a sequential game.

    Math & Bit Manipulationprobabilityexpected-valuerecursion
  • Data Structure DesignMediumAuto-graded
    Round-Robin Task Distribution with Dynamic Server Availability

    Tests stateful simulation with circular iteration, capacity tracking, and toggling availability flags.

    Data Structure Designsimulationcircular-iterationstate-management
  • Greedy & IntervalsHardAuto-graded
    Minimum Adjacent Swaps to Sort a Binary String

    Tests greedy inversion-counting on a binary string to find the minimum number of adjacent swaps needed to push all 1s to the right.

    Greedy & Intervalsgreedystringsinversion-count
  • Trees & GraphsMediumAuto-graded
    Compute Reporting Metrics in a Company Hierarchy

    Tests tree construction from parent pointers and post-order traversal to aggregate counts across nested organizational levels.

    Trees & Graphstreedfspost-orderrecursion
  • Arrays & HashingMediumAuto-graded
    Cluster Viewers by Recent Watch Set

    Tests dictionary grouping, set operations on list suffixes, and canonical key construction for equivalence classes.

    Arrays & Hashinghash-mapset-operationsgrouping
  • Data Structure DesignMediumAuto-graded
    Replay Operations Against an LRU Cache

    Replay a scripted sequence of get/put operations against a fixed-capacity LRU cache and return one result per operation.

    Data Structure Designlru-cachehash-mapsimulationordered-dict
  • Arrays & HashingMediumAuto-graded
    Verify Safe Spacing During Multi-Vehicle Forward Simulation

    Tests discrete-time physics simulation with kinematic updates and safety constraint checking across multiple moving objects.

    Arrays & Hashingsimulationphysicsiteration
  • StringsMediumModel answer
    Build a Holiday Gift Matcher from CSV Input

    Parse participant data from a CSV string with quoted fields, validate entries, and create a round-robin assignment where no one gives a gift to themselves.

    Stringsparsingvalidationalgorithmscsv
  • Trees & GraphsMediumModel answer
    Cluster Exposures: Net Change per Asset Group

    Find connected components in an asset correlation graph and return the summed position delta for each component as a labeled group.

    Trees & Graphsgraph traversalconnected componentshash mapDFS
  • Heaps, Sorting & SearchMediumAuto-graded
    Unique Element Count via Binary Search Jumps

    Count unique values in a sorted array by jumping between runs using binary search, achieving sublinear time when diversity is low.

    Heaps, Sorting & Searchbinary-searcharrayssorted-arrayoptimization
  • Arrays & HashingMediumAuto-graded
    Compute Spending Totals by Worker, Journey, and Type

    Tests efficient multi-key aggregation using hash maps to group and sum records in a single pass over large datasets.

    Arrays & Hashinghash-mapsaggregationgrouping
  • Trees & GraphsHardAuto-graded
    Safe Edge Insertion Check for a Dependency Graph

    Tests graph reachability and cycle detection: determine whether a new directed edge can be added to an acyclic dependency graph without introducing a cycle.

    Trees & Graphsgraphsdepth-first-searchcycle-detectionreachability
  • Heaps, Sorting & SearchMediumAuto-graded
    Task Scheduler with Parallel Workers

    Simulate dispatching sequential tasks to parallel workers and determine when all work completes.

    Heaps, Sorting & Searchheapsimulationgreedy
  • Arrays & HashingMediumAuto-graded
    Valid Subsets Bounded by Their Spread

    Count non-empty index-distinct subsets where the smallest plus largest value stays within a limit, using sorting, two pointers, and modular arithmetic.

    Arrays & Hashingtwo-pointerssortingcombinatorics
  • Data Structure DesignMediumModel answer
    Duplicate-Aware Collection with O(1) Random Sampling

    Design a multiset supporting insert, remove, and uniform random sampling over all occurrences, each in expected O(1) time.

    Data Structure Designhash-maparrayrandomnessdata-structure-design
  • Data Structure DesignHardAuto-graded
    Build a Record Filter with Nested Query Conditions

    Evaluate structured filter expressions with comparison, membership, and logical operators over in-memory records

    Data Structure Designrecursiondata-structuresquery-evaluation
  • Dynamic ProgrammingHardAuto-graded
    Maximize Hourly Output Revenue for a Three-Stage Assembly Line

    Tests budgeted 0/1 selection with a bottleneck objective, requiring Pareto-frontier pruning over a four-dimensional knapsack state space.

    Dynamic Programmingknapsackpareto-frontierbottleneckcombinatorial-optimization
  • Data Structure DesignEasyAuto-graded
    Find Minimum Index Gap Between Word Pairs

    Tests the ability to preprocess data for efficient repeated lookups using hash maps and two-pointer merging of sorted lists.

    Data Structure Designhash-maptwo-pointerspreprocessing
  • Heaps, Sorting & SearchHardModel answer
    Locate Local Minima Using Divide-and-Conquer

    Implement sublinear algorithms to identify a local minimum in a 1D array and a 2D grid by applying binary search to unimodal descent.

    Heaps, Sorting & Searchbinary-searchdivide-and-conqueralgorithms
  • StringsEasyAuto-graded
    Total Palindrome Substrings in a String

    Tests your ability to count every palindromic substring by expanding around centers or applying Manacher's linear-time algorithm.

    Stringsstringsdynamic-programmingtwo-pointers
  • Data Structure DesignEasyModel answer
    Two-Part Challenge: Token Frequencies and Multiset Overlap with a Barebones RDD

    Using only flatMap, groupByKey, union, and collect on a minimal RDD class, implement word counting and a duplicate-preserving intersection of two datasets.

    Data Structure Designrddword-countmultiset-intersection
  • StringsEasyAuto-graded
    First Longest Window of Distinct Characters

    Tests whether a candidate can apply the sliding window technique with a hash map to find the earliest, longest non-repeating character run in a string.

    Stringssliding-windowhash-maptwo-pointers
  • Heaps, Sorting & SearchMediumAuto-graded
    Top-K Labels by Frequency with Alphabetical Tie-Breaking

    Tests frequency counting and compound-key sorting to find the k most common strings, resolving ties by alphabetical order for both ranking and inclusion.

    Heaps, Sorting & Searchsortinghash-mapheap
  • Data Structure DesignMediumAuto-graded
    Deduplicate Repeated Log Messages with Time Window

    Filter a time-ordered stream of log messages to show each distinct message only once per 10-second window

    Data Structure Designhash-mapstreamingrate-limiting
  • Trees & GraphsMediumAuto-graded
    Shortest Route Through a Blocked Matrix

    Find the minimum number of unit moves from the top-left to the bottom-right cell of a 0/1 matrix, or report that no route exists.

    Trees & Graphsbfsgridshortest-pathgraph-traversal
  • Data Structure DesignMediumAuto-graded
    Simulate an In-Memory Key-Value Store

    Tests ability to implement a command-driven key-value store with correct upsert, lookup, conditional update, delete, and membership semantics.

    Data Structure Designhash-tablesimulationdesign
  • Linked ListsHardAuto-graded
    Find Where Two Linked Lists Merge

    Tests pointer manipulation and list traversal to locate the merge point of two singly linked lists in linear time with constant space.

    Linked Liststwo-pointerslinked-listspointer-manipulation
  • Arrays & HashingMediumAuto-graded
    Next Ace Probability Given at Least One Ace Already Drawn

    Tests conditional probability over sampling without replacement, combining hypergeometric counting with Bayes' theorem to handle a "at least one" conditioning event.

    Arrays & Hashingconditional-probabilitycombinatoricshypergeometric