Coding interview questions

Practice live coding questions organized around core patterns, invariants, edge cases, and time-space complexity so you can explain tradeoffs cleanly while writing code under time pressure.

22 question breakdowns

CodingMedium

Implement a Trie with Insert, Search, Prefix, and Delete

Derive a Trie from exact-match and prefix requirements, implement safe deletion without damaging shared paths, and verify the terminal-marker invariant, complexity, and adversarial cases.

Open the question and answer
CodingMedium

Dijkstra's Algorithm: Coding Interview Guide

Implement Dijkstra with an adjacency list, lazy heap deletion, and path rebuild; prove the greedy invariant and negative-edge limits.

Open the question and answer
CodingHard

Coding Interview: How Do You Implement an O(1) LFU Cache?

Implement an LFU cache with a key index, frequency buckets, per-bucket doubly linked lists, and a minimum-frequency pointer, then prove expected O(1) get and put.

Open the question and answer
CodingHard

Coding Interview: How Do You Solve Word Ladder with Bidirectional BFS?

Model Word Ladder as an implicit unweighted graph, derive BFS from the shortest-sequence contract, and implement a smaller-frontier bidirectional search with a precise proof, cost model, and adversarial tests.

Open the question and answer
CodingHard

Coding Interview: How Do You Find the Longest Increasing Subsequence?

Derive the minimum-tail invariant from quadratic dynamic programming, then use binary search, predecessor indices, and property tests to implement and prove an O(n log n) longest increasing subsequence algorithm.

Open the question and answer
CodingHard

Coding Interview: Find All Critical Connections in a Network

Find every bridge in an undirected graph with discovery times and low-link values, then prove the strict bridge condition and implement a stack-safe iterative DFS.

Open the question and answer
CodingHard

Coding Interview: Implement a Thread-Safe Read-Write Lock

Implement a read-write lock with a mutex and condition variables, then reason about fairness, upgrades, and failure cases.

Open the question and answer
CodingMedium

Coding interview: How would you implement an O(1) minimum stack?

Maintain a prefix-minimum stack so push, pop, top, and getMin run in O(1), including duplicate minima and empty-stack behavior.

Open the question and answer
CodingMedium

Coding Interview: How Do You Implement a Dynamic Array and Prove Amortized O(1) Append?

Use capacity invariants, geometric growth, and an amortized proof to implement an indexable dynamic array and explain space and worst-case costs.

Open the question and answer
CodingHard

Coding interview: How do you maximize reward with non-overlapping jobs?

Use weighted interval scheduling to connect sorting, binary search, and dynamic programming, with precise boundaries, proof, complexity, and reconstruction.

Open the question and answer
CodingHard

How do you implement a Count-Min Sketch for streaming frequency estimates?

Use a two-dimensional counter array and independent hashes to estimate key frequencies in fixed memory, including error bounds, merges, and reset limits.

Open the question and answer
CodingHard

Coding Interview: Implement a Time-Versioned Key-Value Store

Implement set/get with per-key version histories and upper-bound binary search, covering out-of-order timestamps, ties, boundaries, and memory trade-offs.

Open the question and answer
CodingHard

Coding Interview: Implement a Hashed Timing Wheel Timer

Manage many approximate timers with a timing wheel while handling cancellation, rotations, long delays, concurrency, and clock precision.

Open the question and answer
CodingHard

How would you implement an LRU-K cache?

Implement a concurrent, bounded LRU-K cache with explainable eviction order, then compare it with LRU approximations and database buffer policies.

Open the question and answer
CodingHard

How would you implement a treap with split and merge?

Derive a treap from BST and heap invariants, covering rotations by composition, duplicate keys, subtree metadata, and expected complexity.

Open the question and answer
CodingMedium

Coding interview: implement a burst-tolerant token-bucket rate limiter

Implement a token-bucket limiter with lazy refill, monotonic time, atomic concurrency, and property-based capacity tests.

Open the question and answer
CodingHard

C++ interview: Implement cooperative cancellation with std::jthread and stop_token

Implement an interruptible C++20 worker with stop requests, cancellable waits, cleanup, exceptions, and automatic joining.

Open the question and answer
CodingHard

Python Coding Interview: When Is Free-Threading Worth Adopting?

Derive an adoption decision for Python free-threading from the GIL, workload shape, and extension compatibility, with migration checks, thread-safety trade-offs, and validation steps.

Open the question and answer
CodingHard

Coding interview: How do you make Rust Tokio code cancellation-safe?

Use select cancellation, partial progress, ownership, and idempotent recovery to write async operations that do not lose state.

Open the question and answer
CodingMedium

How would you implement a gap buffer for a text editor?

Implement cursor movement, insertion, deletion, growth, and invariants for a gap buffer, then explain when a piece table or rope is a better fit.

Open the question and answer
CodingHard

Coding Interview: Implement a Radix Tree for Prefix Routing

Build insert, exact lookup, longest-prefix lookup, and delete with path compression, then defend invariants, complexity, and edge cases.

Open the question and answer
CodingMedium

Coding Interview: Solve Next Greater Element II with a Monotonic Stack

Treat a circular array as two bounded index passes and use a decreasing monotonic stack to find every next strictly greater value in linear time.

Open the question and answer