KatInterview

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

Coding Interview Problems

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

6048
Problems
2239
Auto-graded
15
Topics
272
Added today

Showing 1441–1470 of 2793 results

  • Trees & GraphsMediumAuto-graded
    Column Grid from a Tree: Reach a Value by Walking Non-Zero Cells

    Project a heap-indexed binary tree onto a depth-by-column grid, then use BFS over non-zero cells to decide whether a cell holding the target is reachable from a given start.

    Trees & Graphsbinary-treebfsgridvertical-order
  • Stacks & QueuesMediumAuto-graded
    Unnest Deeply Nested Lists Without Recursion

    Flatten an arbitrarily nested Python list into a single list in left-to-right order, treating only lists as containers and handling very deep nesting safely.

    Stacks & Queuesstackiterationnested-listsdepth-first-search
  • Trees & GraphsMediumAuto-graded
    Eager Formula Sheet with Cycle-Safe Updates

    Simulate a mini spreadsheet where formulas are evaluated at write time, dependents update eagerly, and any write that would create a dependency cycle is rejected without changing state.

    Trees & Graphsdependency graphtopological sortcycle detectionsimulation
  • Trees & GraphsMediumAuto-graded
    Duplicate a Nested Structure With Cycles and Shared Parts

    Build an independent deep copy of a nested container structure, preserving shared references and cycles, using a memo table and an explicit stack.

    Trees & Graphsdeep-copygraph-traversalmemoizationiterative-dfs
  • Data Structure DesignMediumAuto-graded
    Spreadsheet Cells With Sum Formulas and Loop Detection

    Simulate a command list on a spreadsheet whose cells hold integers or two-reference sum formulas, evaluating lazily and reporting circular references.

    Data Structure Designgraphdfscycle-detectionsimulation
  • Heaps, Sorting & SearchMediumModel answer
    Streaming Word Frequencies from an Oversized Text File

    Build a memory-safe word counter for a huge text file, define tokenization rules, return the top-k words deterministically, and discuss what to do when the vocabulary strains memory.

    Heaps, Sorting & Searchword-countstreaminghash-maptop-k
  • Heaps, Sorting & SearchHardAuto-graded
    Pick the Bottle Kit With the Least Leftover Volume

    Choose the bottle kit that serves every dose request with minimal total leftover space, using sorting, prefix sums and binary search to stay efficient on large inputs.

    Heaps, Sorting & Searchbinary-searchprefix-sumssortinggreedy
  • Trees & GraphsMediumModel answer
    Crawl a Web-Served Labyrinth Through Unreliable Responses

    Write a crawler that explores a maze of HTTP endpoints to find the exit, coping with cycles, transient 503 errors and malformed JSON, while guaranteeing termination.

    Trees & Graphsgraph-traversalbfshttpretries
  • Math & Bit ManipulationMediumAuto-graded
    Matrix Product, Fast Power and Fibonacci Toolkit

    Combine matrix multiplication, square-and-multiply exponentiation and 2x2 matrix-power Fibonacci, with optional modular arithmetic, in one function.

    Math & Bit Manipulationmatrix-multiplicationfast-exponentiationfibonaccimodular-arithmetic
  • StringsMediumModel answer
    Bootstrapping a Reproducible Python Environment with Bash

    Write and explain a Bash script that creates or reuses a Python virtual environment and installs dependencies, covering strict mode, idempotency, activation pitfalls, and resulting files.

    Stringsbashshell-scriptingpython-venvautomation
  • Data Structure DesignMediumAuto-graded
    Most Likely Follower Lookup via Operation Log

    Simulate a bigram next-word model from an operation log, returning the most frequent follower with lexicographic tie-breaking and an empty string when none exists.

    Data Structure Designhash-mapdesigncountingsimulation
  • Arrays & HashingMediumAuto-graded
    Column-wise Gap Filling with Mean, Median or Mode

    Fill None cells in a table column by column with the mean, median or smallest-most-frequent value of the observed entries, without mutating the input.

    Arrays & Hashingarrayssimulationstatisticsdata-cleaning
  • Data Structure DesignMediumModel answer
    Card Prefix Registry with Per-Field Trust Resolution

    Design an in-memory registry mapping digit prefixes to brand and card type, resolving each field by longest prefix, then trust, then recency, with fast lookups.

    Data Structure Designhash-maplongest-prefix-matchtriedata-structure-design
  • StringsMediumAuto-graded
    Longest Repeat-Free Concatenation, Lexicographically Smallest

    Pick words and order them to form the longest string with no repeated character, breaking ties by smallest lexicographic order; tests subset backtracking with disjoint-set pruning.

    Stringsbacktrackingsubsetsstringsbitmask
  • Trees & GraphsMediumAuto-graded
    Uncover Cells on a Minefield Grid with Flood Expansion

    Apply a Minesweeper-style tap to a grid, expanding through zero-mine regions with breadth-first search and labeling cells with adjacent mine counts.

    Trees & Graphsbfsgridmatrixsimulation
  • Data Structure DesignMediumAuto-graded
    Restaurant Queue Tracker with Fast Rank Lookup

    Replay a list of queue operations on a first-come waitlist, supporting add, remove-by-id, rank lookup and front peek, with rank queries faster than a linear scan.

    Data Structure Designdesignorder-statistictreaphash-map
  • Trees & GraphsMediumAuto-graded
    Grid Distance to the Closest Marked Cell

    Compute, for every cell of a grid, the fewest orthogonal steps to the closest marked cell, using a single multi-source breadth-first search; -1 everywhere when no cell is marked.

    Trees & Graphsbfsmulti-source-bfsgridshortest-path
  • Math & Bit ManipulationHardAuto-graded
    Ordered IPv4 Access List: Verdict for an Address or Entire Subnet

    Evaluate an ordered first-match IPv4 access list for a single address or a whole CIDR block, which needs prefix arithmetic and interval reasoning rather than enumerating addresses.

    Math & Bit Manipulationcidrbit-manipulationstacksorting
  • Trees & GraphsMediumAuto-graded
    Chained Exchange Rates: Resolve Conversion Queries

    Build a bidirectional weighted graph from exchange rates and answer conversion queries with a deterministic BFS that multiplies rates along the first-found path, or -1.0 if none exists.

    Trees & Graphsgraphbfsweighted-graphhash-map
  • Math & Bit ManipulationEasyAuto-graded
    Expected Draws Until a Second Distinct Token Shows Up

    Compute, as a floating-point number, the expected number of draws from a fixed three-outcome distribution until two different outcomes have appeared, using conditioning and geometric waiting times.

    Math & Bit Manipulationprobabilityexpected-valuegeometric-distributionmath
  • Arrays & HashingHardAuto-graded
    Complete a Partially Filled Number Grid with Row, Column, Box Rules

    Fill in the blanks of a 9x9 digit grid so every row, column and 3x3 block holds each digit 1-9 once, testing backtracking with constraint pruning.

    Arrays & Hashingbacktrackingconstraint-satisfactionbitmaskrecursion
  • Arrays & HashingMediumAuto-graded
    Rainwater Held Between Terrain Columns

    Compute total rainwater stored between unit-width columns of given heights, aiming for a single pass with constant extra memory using the two-pointer technique.

    Arrays & Hashingtwo-pointersarraysgreedy
  • Dynamic ProgrammingMediumAuto-graded
    Cheapest Right-Down Route Through a Cost Grid

    Compute the minimum total cost of a route from the top-left to the bottom-right of a grid when only right and down moves are allowed, using dynamic programming.

    Dynamic Programmingdynamic-programminggridmatrixoptimization
  • Heaps, Sorting & SearchMediumAuto-graded
    Rank Anti-Diagonal Strings of a Letter Grid

    Build a string for each anti-diagonal of a letter grid, read bottom-left to top-right, and return diagonal indices ordered by string, with ties broken by index.

    Heaps, Sorting & Searchmatrixsortingstringstie-breaking
  • Trees & GraphsMediumAuto-graded
    Is the Target's Cell Forced by Every Valid Seating?

    Backtracking over placements of named items on a grid under pairwise relative-position clues, deciding whether the target ends up in one cell across all valid layouts.

    Trees & Graphsbacktrackingconstraint-satisfactiongridsearch
  • Data Structure DesignMediumModel answer
    Fast Machine Selection for a Memory-Aware Table Placer

    Redesign a slow in-memory placer so it finds a machine with enough free RAM, resizes tables, and moves them quickly, while justifying a placement policy.

    Data Structure Designdata-structure-designbisectbest-fitscheduling
  • Arrays & HashingEasyAuto-graded
    Locate Two Entries That Add Up to a Goal

    Find the two distinct positions in an integer list whose values sum to a goal, using a single-pass hash map lookup instead of checking every pair.

    Arrays & Hashinghash-maparrayscomplement-lookup
  • Data Structure DesignMediumAuto-graded
    Multiset Frequency Log with Lazy Snapshot Pool Top-K

    Simulate insert, remove and top-k queries on a multiset using a snapshot pool whose stale entries are discarded lazily, testing hash maps with heaps and exact rule-following.

    Data Structure Designhash-mapheaplazy-deletiondesign
  • Trees & GraphsHardAuto-graded
    Semester Planner Plus Burst-Limited Request Filter

    Combine topological ordering to find the minimum number of semesters (or detect a cycle) with a deque-based simulation of a two-rule request throttle that reports dropped timestamps.

    Trees & Graphstopological-sortgraphcycle-detectionsliding-window
  • StringsMediumAuto-graded
    Locate the First Occurrence of a Needle in a Haystack

    Find the earliest starting index of a pattern inside a text in linear time, handling empty inputs and repetitive patterns, using a prefix-function (KMP-style) scan.

    Stringsstringskmptwo-pointerspattern-matching