KatInterview

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

Coding Interview Problems

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

6045
Problems
2239
Auto-graded
15
Topics
275
Added today

Showing 1501–1530 of 2792 results

  • Greedy & IntervalsMediumAuto-graded
    Booked Time and Peak Room Demand for a Schedule

    Compute the total time covered by a set of half-open intervals and the maximum number of simultaneously active intervals, ignoring empty or reversed ones.

    Greedy & Intervalsintervalssweep-linesortingmerge-intervals
  • Arrays & HashingMediumAuto-graded
    Batch Gradient Descent Linear Regression Session Simulator

    Simulate a fit/predict command sequence for a linear model trained with batch gradient descent on mean squared error, using plain Python lists.

    Arrays & Hashinggradient-descentlinear-regressionmsesimulation
  • Heaps, Sorting & SearchMediumAuto-graded
    Cheapest Full Merge and Matching-Sum Product Total

    Combine a Huffman-style min-heap greedy for the cheapest full merge with a frequency-map count of index pairs hitting a target sum, summing their products.

    Heaps, Sorting & Searchheapgreedyhash-mapcounting
  • Data Structure DesignHardModel answer
    Build a Accessible, Controllable Select Menu in React

    Design and implement a reusable select-style menu in React with controlled and uncontrolled state, keyboard support, ARIA semantics, and a plan for production hardening.

    Data Structure Designreactfrontendaccessibilitycomponent-design
  • Data Structure DesignMediumAuto-graded
    Lifespan Lookups for Orders and Order Groups in a Replay Log

    Simulate a class through an operations list, tracking per-order and per-group start and end times so lookups run in constant time, with groups reporting 0 while any member is open.

    Data Structure Designhash-mapdesignsimulationaggregation
  • Data Structure DesignHardModel answer
    Live Portfolio Valuation Across Tag-Filtered Books

    Design a class that maintains mark-to-market profit for many tag-filtered trade groups while trades and price ticks stream in, without rescanning trade history on each update.

    Data Structure Designdesignhashingincremental-updatelazy-evaluation
  • StringsEasyAuto-graded
    Tab-Scoped Ticket Search with Case-Insensitive Matching

    Filter support tickets by tab, then by a case-insensitive substring match on title or assignee, handling blank queries and unassigned tickets.

    Stringsstringsfilteringcase-insensitivesimulation
  • Trees & GraphsMediumModel answer
    Crawl One Site: Sequential Traversal, Then a Parallel Version

    Collect every page reachable from a seed URL on the same host, ignoring URL fragments and fetching each page once, first with one thread and then with safe concurrency.

    Trees & Graphsweb-crawlerbfsconcurrencythread-safety
  • Arrays & HashingMediumAuto-graded
    Remainder-Sum Windows and Bracket Cleanup

    Count contiguous subarrays whose sum has a given remainder using prefix-sum remainders, and delete the fewest parentheses to balance a string in a fixed, deterministic way.

    Arrays & Hashingprefix-summodular-arithmetichash-countinggreedy
  • Heaps, Sorting & SearchMediumAuto-graded
    One-Car Sweep Scheduler: Order the Elevator Stops

    Order a single elevator's pending floor requests using a one-reversal sweep policy with a priority queue, merging duplicates and respecting the starting direction.

    Heaps, Sorting & Searchheappriority-queuesortingsimulation
  • Data Structure DesignMediumModel answer
    Minesweeper Solver: Deduction Rules and Mine Probabilities

    Design a Minesweeper bot that derives certain mines and safe cells from overlapping numbers, estimates mine probabilities when it must guess, and is evaluated by win rate.

    Data Structure Designminesweeperconstraint-satisfactionprobabilitybacktracking
  • Trees & GraphsMediumModel answer
    Print a Reporting Hierarchy and List Two-Level-Down Pairs

    Turn manager rows into a tree, infer the root, print it with depth-based dot indentation, or list every (manager, employee) pair exactly two levels apart.

    Trees & Graphstreepreorderiterative-dfshash-map
  • Trees & GraphsMediumAuto-graded
    Cheapest Letter Rewrites with Directed Price Rules

    Compute the minimum cost to rewrite one string into another with directed priced letter swaps, using shortest paths over 26 letters and handling impossible positions and large totals.

    Trees & Graphsgraphfloyd-warshallshortest-pathstrings
  • Data Structure DesignMediumAuto-graded
    Duplicate Log Suppression Within a Cooldown Window

    Simulate a duplicate-log filter driven by an operation script, tracking per-message cooldowns where only accepted messages restart the timer.

    Data Structure Designhash-mapdesignsimulationrate-limiting
  • Trees & GraphsMediumAuto-graded
    Fewest-Hop Route Through Flaky Page Fetches

    Run BFS on a link graph to find the lexicographically smallest fewest-hop route, where some pages fail a set number of times before their links load.

    Trees & Graphsbfsgraphshortest-pathretries
  • Trees & GraphsMediumAuto-graded
    Rainbow Walks of Length Three in a Typed Graph

    Count ordered 4-vertex walks along edges in an undirected graph whose vertices carry one of four labels, where each walk uses every label exactly once.

    Trees & Graphsgraphcountingcombinatoricsadjacency-list
  • Math & Bit ManipulationEasyAuto-graded
    Eventual Winner Odds in a Draw-Two Card Duel with Replays

    Compute the probability that the first of two drawers eventually wins a rank-comparison game with replayed ties, using counting and a symmetry argument.

    Math & Bit Manipulationprobabilitysymmetrycountingmath
  • Linked ListsMediumModel answer
    Sequence Storage Trade-offs: Contiguous Arrays vs Pointer Chains

    Contrast contiguous arrays, linked lists, and unrolled lists for indexed reads, inserts, growth, traversal speed, and cache behavior, and say when each one wins.

    Linked Listsarrayslinked-listsunrolled-linked-listcache-locality
  • Data Structure DesignMediumAuto-graded
    Slide a Block in a Grid and Filter Repeated Log Calls

    Move a rectangular block inside a 2D grid without corrupting overlapping data, then run a sliding-window duplicate filter over a list of timestamps.

    Data Structure Designmatrixin-placesliding-windowdeque
  • Trees & GraphsMediumAuto-graded
    Earliest Finish Time for a Dependent Task Pipeline

    Find the minimum time to complete all tasks with durations and prerequisites under unlimited parallelism, or detect a circular dependency, using longest path in a DAG with topological ordering.

    Trees & Graphstopological-sortgraphdaglongest-path
  • Heaps, Sorting & SearchMediumAuto-graded
    First Index at Least Target in a Padded Sorted Stream

    Find the first index with value at least the target in a sorted sequence of hidden length, using doubling probes followed by binary search.

    Heaps, Sorting & Searchbinary-searchexponential-searchsorted-arrayinvariants
  • Data Structure DesignMediumModel answer
    Singleton, Factory Method and Strategy: Code and Compare in Java

    Write Java versions of a lazy thread-safe Singleton, a Factory Method and a Strategy, weigh them against each other, then refactor a Singleton dependency to use injection.

    Data Structure Designdesign-patternsjavasingletonfactory-method
  • Trees & GraphsMediumAuto-graded
    Flip Pipes to Flow Outward From a Source Station

    Count the directed edges of a tree that point toward a chosen root, which is the minimum number of flips needed to orient every edge away from it.

    Trees & Graphstreegraph-traversaldfsbfs
  • Trees & GraphsMediumAuto-graded
    Grid Contagion with Neighbor-Count Thresholds

    Compute when each grid cell becomes infected under a synchronous neighbor-count rule, using a multi-source BFS that updates counts incrementally instead of rescanning each round.

    Trees & Graphsbfsgridsimulationmulti-source-bfs
  • Data Structure DesignMediumModel answer
    In-Memory Ledger with Ranking by Total Money Sent

    Build an in-memory ledger supporting account creation, deposits and transfers, plus a query returning the top n senders by cumulative outgoing amount with deterministic tie-breaking.

    Data Structure Designdata-structure-designhash-mapheaptop-k
  • Heaps, Sorting & SearchMediumAuto-graded
    Expiring Compute Credits: Offline Ledger Replay

    Replay a shuffled log of credit grants, spends and balance queries in time order, spending the soonest-expiring credits first, using a heap and sorting.

    Heaps, Sorting & Searchheapsortingsimulationoffline-processing
  • Trees & GraphsMediumAuto-graded
    Leftmost and Rightmost Nodes per Depth from a Serialized Tree

    Given a level-order serialized binary tree, return the first and last node value at each depth, testing BFS over an array-encoded tree and careful handling of null slots.

    Trees & Graphsbinary-treebfslevel-orderserialization
  • Heaps, Sorting & SearchMediumAuto-graded
    Median Tracker for an Incoming Number Feed

    Maintain the median of a growing sequence after each new value arrives, testing efficient order-statistic upkeep with a pair of heaps.

    Heaps, Sorting & Searchheaptwo-heapsstreamingmedian
  • Trees & GraphsMediumAuto-graded
    Longest Path Between Any Two Nodes in an Indexed Binary Tree

    Find the longest path, counted in edges, between any two nodes of a binary tree stored as a child-index list, testing tree height computation and avoiding deep recursion.

    Trees & Graphsbinary-treedfsbfstree-height
  • Greedy & IntervalsMediumAuto-graded
    Pick One Day Per Workshop Within Its Availability Window

    Choose a distinct day for as many workshops as possible, each within its own window, using an earliest-deadline-first greedy with a min-heap.

    Greedy & Intervalsgreedyheapintervalssorting