KatInterview

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

Coding Interview Problems

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

5969
Problems
2211
Auto-graded
15
Topics
273
Added today

Showing 61–90 of 2761 results

  • Arrays & HashingMediumAuto-graded
    Quickest Kilometer Within a Run Recorded in 5-Second Splits

    Find the highest average speed over any 1000 m stretch of a run given per-5-second distances, using prefix sums, binary search and interpolation at boundaries.

    Arrays & Hashingprefix-sumsbinary-searchsliding-windowinterpolation
  • Trees & GraphsMediumAuto-graded
    Group Staff Names by Reporting Depth

    Turn flat employee-manager records into a list of name groups by depth from the top manager, using a level-by-level breadth-first traversal.

    Trees & Graphsbfstreehash-maplevel-order
  • StringsMediumAuto-graded
    Longest Window With a Capped Number of Distinct Letters

    Find the length of the longest contiguous stretch of a string using no more than k different characters, testing the sliding-window technique with a frequency map.

    Stringssliding-windowtwo-pointershash-mapstrings
  • Math & Bit ManipulationMediumAuto-graded
    Fit a Line by Batch Gradient Descent with Standardized Input

    Implement full-batch gradient descent for a one-feature least-squares line, standardizing the input, and map the learned parameters back to the original scale.

    Math & Bit Manipulationgradient-descentlinear-regressionnumericalfeature-scaling
  • Dynamic ProgrammingMediumAuto-graded
    Climbing the Tallest Staircase Through a Height Map

    Find the longest chain of strictly rising values in a grid using only up, down, left, right steps, which tests DP over an implicit DAG with a valid processing order.

    Dynamic Programmingdynamic-programminggridtopological-ordermemoization
  • Arrays & HashingEasyAuto-graded
    Earliest Strict Valley in an Integer Sequence

    Scan an integer list for the leftmost interior value strictly smaller than both adjacent values, returning -1 if none exists, which tests boundary handling and strict comparisons.

    Arrays & Hashingarrayscanboundary-conditionsstrict-comparison
  • Data Structure DesignMediumAuto-graded
    Stream Merging Iterator for Two Ordered Sequences

    Simulate a stateful iterator that lazily combines two strictly sorted sequences into a single sorted, duplicate-free stream using constant space.

    Data Structure Designdesign-dsarraysheaps-sorting
  • Data Structure DesignMediumAuto-graded
    Wildcard Word Dictionary Simulator

    Simulate a word store that answers pattern queries where '.' stands for any single letter, which is best handled with a prefix tree and a depth-aware traversal.

    Data Structure Designtriedesignwildcarddfs
  • Heaps, Sorting & SearchEasyAuto-graded
    Last Stone Standing: Repeated Smash of the Two Heaviest Weights

    Simulate repeatedly removing the two largest values and reinserting their difference, using a max-heap to find the last remaining value or 0.

    Heaps, Sorting & Searchheappriority-queuesimulation
  • Trees & GraphsMediumAuto-graded
    Web Crawling Discovery and Bracket Syntax Check

    Perform a depth-bounded graph traversal over web pages based on domain filtering, and validate balanced brackets using a stack.

    Trees & Graphsbfsgraph-traversalstackstring-validation
  • Data Structure DesignMediumAuto-graded
    Sliding Window Stream Aggregator

    Design a memory-efficient real-time streaming data structure to query moving averages over a sliding temporal window.

    Data Structure Designsliding-windowdequedesignstream-processing
  • Stacks & QueuesMediumModel answer
    Line of Sight Counts for Each Person in a Row

    For each person in a row, count how many people further right they can see when anyone standing between must be shorter than both of them. Needs an O(n) approach.

    Stacks & Queuesmonotonic-stackarraysamortized-analysisnext-greater-element
  • Trees & GraphsMediumAuto-graded
    Fast Power Residue Plus Nearest-Source Grid Map

    Combine square-and-multiply modular exponentiation with a multi-source BFS that labels every grid cell with its distance to the nearest source cell.

    Trees & Graphsbfsmodular-exponentiationgridmulti-source-bfs
  • Data Structure DesignMediumModel answer
    Versioned Follow Graph with Time-Travel Queries and Suggestions

    Build an in-memory directed follow graph with cheap snapshots, historical edge lookups, and a friends-of-friends suggestion ranking with id tie-breaks.

    Data Structure Designgraphsnapshotsbinary-searchheap
  • Arrays & HashingMediumAuto-graded
    Chain-Reaction Tile Clearing on a Grid

    Simulate a grid game where runs of three or more equal tiles vanish together, tiles fall down, and the process repeats until the grid is stable.

    Arrays & Hashingsimulationmatrixtwo-pointersgrid
  • StringsEasyAuto-graded
    Valid Palindrome with At Most One Removal

    Determine whether a given string can be converted into a palindrome by removing no more than one character.

    Stringsstringstwo-pointers
  • Arrays & HashingMediumAuto-graded
    Find Members Missing a Nearby Provider Specialty

    Given providers and members on a 2D plane, find members with a required specialty that has no provider within a distance limit, using hashing and spatial grouping.

    Arrays & Hashinghashinggeometrygrid-bucketingsimulation
  • Data Structure DesignMediumModel answer
    Live Scoreboard Engine for One Tennis Game

    Process a sequence of point winners for a single tennis game and print the correct score after each point, including deuce, advantage and the win-by-two rule.

    Data Structure Designsimulationstate-designclass-designedge-cases
  • Data Structure DesignMediumAuto-graded
    In-Memory Bank Ledger with Pending Transfers and Expiry

    Simulate an in-memory banking system processing sequential operations, pending transfers with fixed-window expiration, and account activity tracking.

    Data Structure DesignData StructuresSimulationDesignHash Table
  • Data Structure DesignEasyAuto-graded
    Duel Resolver: Speed, Types and Chip Damage

    Simulate a two-creature duel with fixed speed order, a minimum-damage floor, and a type-advantage multiplier, then return the winner's name.

    Data Structure Designsimulationdictionariesfloating-pointgame-logic
  • Trees & GraphsMediumAuto-graded
    Merge Accounts Into Groups via Weighted Field Matching

    Group records into clusters where records are linked when their name/email match score reaches a cutoff, using union-find and bucketing on exact field values.

    Trees & Graphsunion-findconnected-componentsgraphhashing
  • Data Structure DesignMediumModel answer
    Snapshot and Restore for an In-Memory String Map

    Build an in-memory string map in C++ that can dump its full state to a byte buffer and rebuild it, handling arbitrary bytes, corrupt input, and failed restores safely.

    Data Structure Designserializationbinary-formathash-mapinput-validation
  • Trees & GraphsMediumAuto-graded
    Anticlockwise Perimeter Walk of an Index-Based Binary Tree

    Compute the anticlockwise perimeter of a binary tree given as child-index arrays, combining root, left edge, leaves and right edge without duplicates.

    Trees & Graphsbinary-treetree-traversaldfsiterative
  • Dynamic ProgrammingHardAuto-graded
    Maximize Priority Sum of Non-Overlapping Tasks

    Find the maximum priority total achievable among non-overlapping interval tasks, prioritizing task count first then total priority.

    Dynamic Programmingdynamic-programminggreedy-intervalsbinary-search
  • Data Structure DesignMediumAuto-graded
    Simulate a Stateful Banking Ledger with Queued Payments

    Simulate an in-memory banking system handling accounts, balances, scheduled payments via a priority queue, and account merges.

    Data Structure Designheaphash-tablesimulationdesign-ds
  • Heaps, Sorting & SearchEasyAuto-graded
    Locate Element in Sorted Array

    Perform logarithmic-time binary search on a strictly increasing array of distinct integers to find a target value's index or detect its absence.

    Heaps, Sorting & Searchbinary-searcharrayssearching
  • Arrays & HashingEasyAuto-graded
    Longest Strictly Rising Streak in a Row of Readings

    Scan an integer list once to find the longest block of adjacent, strictly rising values, handling empty input, equal neighbors, and runs that reach the end.

    Arrays & Hashingarrayssliding-windowtwo-pointerslinear-scan
  • Heaps, Sorting & SearchMediumModel answer
    Rolling Window Medians with Two Heaps and Lazy Removal

    Return the median of every length-k window of an integer array in O(n log k) time, handling duplicates, removals of departing elements, and the even-k convention.

    Heaps, Sorting & Searchsliding-windowheapmedianlazy-deletion
  • StringsMediumAuto-graded
    Spoken Amount Decoder: English Words to Signed Integer

    Parse an English number phrase (up to millions, optional "negative" prefix) into its integer value using a single left-to-right pass with group accumulators.

    Stringsstring-parsingtokenizationhash-mapsimulation
  • Data Structure DesignMediumModel answer
    Thread-Safe Ledger for Courier Payouts and Client Invoices

    Design an in-memory, thread-safe ledger that upserts delivery records and serves instant per-courier earnings and per-client invoice totals in integer cents.

    Data Structure Designconcurrencyhash-mapincremental-aggregationlow-level-design