KatInterview

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

Coding Interview Problems

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

5971
Problems
2211
Auto-graded
15
Topics
272
Added today

Showing 91–120 of 2761 results

  • Dynamic ProgrammingMediumModel answer
    Prune Minimum Nodes from Tree to Satisfy Height Budget

    Determine the minimal set of non-root node deletions required to trim a multi-child tree's height down to a target limit under node-promotion rules.

    Dynamic Programmingtrees-graphsdynamic-programmingtree-dp
  • Trees & GraphsMediumAuto-graded
    Smallest-ID Study Order for One Goal Course

    Restrict a dependency graph to the ancestors of one goal node, then produce the smallest-ID-first topological order, or an empty list if a cycle blocks it.

    Trees & Graphstopological-sortgraphheapcycle-detection
  • Math & Bit ManipulationMediumAuto-graded
    Whole-Share Rebalancing for a Fractional Stock Ledger

    Simulate customer buy and sell orders against fractional inventory, trading only whole shares with the market, and emit ordered transfer logs and final balances.

    Math & Bit Manipulationsimulationstring-parsinginteger-arithmetichash-map
  • Heaps, Sorting & SearchMediumModel answer
    Three Classics: Spaced Characters, Merged Streams, Cloned Lists

    Solve three linked tasks: rearrange a string so no neighbors match, merge k sorted linked lists, and deep-copy a linked list whose nodes carry an extra arbitrary pointer.

    Heaps, Sorting & Searchheapgreedylinked-liststring
  • Data Structure DesignMediumModel answer
    Design a Custom CSV Parsing and Filtering Engine

    Implement an in-memory CSV query processor with auto-type inference and polymorphic field filtering.

    Data Structure Designparsingdesign-dsstringsarrays
  • Trees & GraphsEasyModel answer
    Count Activations per Node in a Cascade Graph

    Given a DAG of task dependencies and one start node, compute how many times each node fires when every activation fans out once along every outgoing edge.

    Trees & Graphsdagtopological-sortpath-countinggraph-traversal
  • Arrays & HashingMediumAuto-graded
    First-Week Post Totals and Week-Later Return Share

    Group dated activity rows by user, find each user's earliest date, total posts in the first seven days, and compute the share of users active on day 7 or later.

    Arrays & Hashinghash-mapdatesaggregationcohort-analysis
  • Heaps, Sorting & SearchMediumModel answer
    Assign Meetings to Rooms and Find the Most-Used One

    Simulate meetings being placed into n numbered rooms, delaying them when all rooms are full, then report the room that hosted the most meetings, preferring the lowest index on ties.

    Heaps, Sorting & Searchheapsimulationpriority-queueintervals
  • Trees & GraphsMediumAuto-graded
    Landmass Tally: Count Regions and Find the Biggest

    Count 4-connected groups of land cells in a binary grid and report the area of the largest group, testing graph traversal with correct visited-state handling.

    Trees & Graphsgraphdfsbfsgrid
  • Data Structure DesignMediumAuto-graded
    RLE Vector Dot Product and Execution Log Processor

    Compress sparse sequences into run-length encodings, calculate their dot product, and analyze nested call timestamps using a call stack.

    Data Structure Designarraysstackstwo-pointersdesign-ds
  • Heaps, Sorting & SearchMediumModel answer
    Top Words in a Huge Text File Under Tight Memory

    Count word frequencies in a text file far larger than RAM, with explicit tokenization rules and an efficient exact top-K, and analyze time, memory and disk costs.

    Heaps, Sorting & Searchword-countstreamingexternal-memorytop-k
  • Heaps, Sorting & SearchEasyAuto-graded
    Locate the Span of a Value in a Sorted List

    Use binary search to find the first and last positions of a value in a sorted list in logarithmic time, returning [-1, -1] when it is absent.

    Heaps, Sorting & Searchbinary-searchsorted-arrayboundaries
  • Greedy & IntervalsMediumAuto-graded
    Coalesce Overlapping Ranges Into Disjoint Spans

    Combine unsorted inclusive integer ranges that share at least one point into disjoint spans ordered by start, testing endpoint handling, chained merges, and nesting.

    Greedy & Intervalsintervalssortinggreedysweep
  • StringsEasyAuto-graded
    Access Log Health Report with Strict Line Validation

    Validate access-log lines field by field, then count client errors, server errors, invalid lines and the failure percentage over the valid lines only.

    Stringsstringsparsingvalidationsimulation
  • Trees & GraphsMediumAuto-graded
    Shortest Word Chain Allowing One or Two Letter Swaps

    Find a shortest word chain where each step swaps one or two letters, with a fixed tie-break, using BFS on an implicit graph and wildcard bucketing for fast neighbor lookup.

    Trees & Graphsbfsshortest-pathstringshashing
  • Data Structure DesignMediumAuto-graded
    Implement a Timed Workspace Credit System

    Process a sequence of timestamped operations managing workspace balances, immediate transfers, scheduled/cancelled future transfers, and ranked queries.

    Data Structure Designheaps-sortingdesign-dsarrays
  • Data Structure DesignMediumAuto-graded
    Spaced Points Stream: Cancel a Nearby Point or Insert

    Maintain a dynamic ordered set of numbers and, per arrival, find the smallest stored value in a closed window around it, deleting it or inserting the newcomer.

    Data Structure Designordered-setbalanced-bstbinary-searchstreaming
  • Data Structure DesignMediumAuto-graded
    Trade Join With Expiring Partial Records

    Simulate a stream join that pairs order and price events by ID, using a min-heap with lazy deletion to expire unmatched partial records.

    Data Structure Designhash-mapheapsimulationstream-processing
  • Math & Bit ManipulationMediumAuto-graded
    Cheapest Acorn Delivery Route for a Chipmunk on a Grid

    Compute the minimum total steps to ferry every item to a single target cell on an open grid, carrying one at a time, using Manhattan distances and a smart choice of the first pickup.

    Math & Bit Manipulationgreedymanhattan-distancegridmath
  • Heaps, Sorting & SearchMediumAuto-graded
    Combine Several Ascending Sequences into One Sorted Sequence

    Merge k individually sorted integer arrays into a single sorted array, testing heap-based k-way merging or pairwise divide-and-conquer and the associated complexity analysis.

    Heaps, Sorting & Searchheapk-way-mergedivide-and-conquersorting
  • Math & Bit ManipulationMediumModel answer
    Runners Dodging Bouncing Sentries Along a Track

    Count how many runners, released one per time unit, cross a track without ever sharing a cell at the same integer time with a sentry that bounces back and forth inside a fixed range.

    Math & Bit Manipulationsimulationmodular-arithmeticperiodic-motionparity
  • Math & Bit ManipulationEasyModel answer
    Invert Bit at Specific Index

    Invert the bit at a given index in a non-negative integer using bitwise operations.

    Math & Bit Manipulationmath-bitsbit-manipulationmath
  • StringsMediumAuto-graded
    Fewest Letter Swaps to Rearrange One Word Into Another's Letters

    Count letter frequencies in two equal-length strings to find the fewest in-place letter replacements that make the second string an anagram of the first.

    Stringsstringshash-mapfrequency-countinganagram
  • Greedy & IntervalsMediumAuto-graded
    Open Half-Hour Slots from Weekly Hours and Bookings

    Expand a weekly schedule over a date range and subtract booked intervals to list every free, half-hour-aligned 30-minute slot in chronological order.

    Greedy & Intervalsintervalsdatetimesimulationsorting
  • StringsEasyAuto-graded
    Mirror Check Ignoring Punctuation and Letter Case

    Check whether a string is a palindrome when only letters and digits count and case is ignored, using two pointers with constant extra space.

    Stringstwo-pointersstringspalindrome
  • Arrays & HashingMediumModel answer
    Weighted Random Index Sampling and Exclusion Product Array

    Implement weighted index sampling with binary search and an exclusion product array without division in O(1) auxiliary space.

    Arrays & Hashingarraysbinary-searchprefix-sum
  • Data Structure DesignMediumModel answer
    Turn-Based Squad Combat Engine with Deterministic Ordering

    Simulate a fight between two squads of monsters with fixed turn order, weakest-first targeting and a damage formula, and return the ordered list of attack events.

    Data Structure Designsimulationobject-oriented-designsortingtie-breaking
  • Arrays & HashingEasyAuto-graded
    Ledger Replay Cleanup: Apply Each Payment Event Once

    Process a stream of possibly redelivered payment events and compute final account balances by applying each unique event ID only once.

    Arrays & Hashinghash-sethash-mapdeduplicationsimulation
  • Data Structure DesignMediumAuto-graded
    Ranking Frequent Event Names Within a Time Window

    Simulate a stream of timestamped log events and answer window queries for the k most frequent messages, with ties broken alphabetically, using binary search over a sorted log.

    Data Structure Designdesignbinary-searchhash-mapsorting
  • Heaps, Sorting & SearchMediumAuto-graded
    Greedy Tile Placement Across Parallel Lanes

    Simulate placing items one by one into the currently lowest lane, breaking ties by lowest index, and report each lane's final total using a min-heap.

    Heaps, Sorting & Searchheapgreedysimulationpriority-queue