Design the Data Structure
Design problems: LRU, LFU, autocomplete, rate limiter, time-series store. Composing data structures into interview-grade systems.
- Chapters
- 7
- Hours
- 2
- Difficulty
- Intermediate to Advanced
- 13.0intermediate
LRU cache: design framing, concurrency, and multi-tier deployment
Pointer rewiring is the warm-up for LeetCode 146. Thread-safety, multi-tier deployment, and Caffeine-style admission policies are the actual interview.
- 13.1advanced
LFU cache: hash map plus frequency-bucketed doubly linked lists
A hash map keyed by frequency, each value a doubly-linked list of equally-frequent entries, plus a min-frequency tracker. The construction that earns LeetCode 460 its Hard rating.
- 13.2intermediate
Min stack and max-frequency stack
Two design problems, one technique. Pin a parallel auxiliary to a stack and the augmented operation collapses to a peek; the auxiliary's shape tracks the contract.
- 13.3intermediate
Hit counter and rate limiter
Fixed-window, sliding-window-log, and token-bucket variants of LC 362 Design Hit Counter, with the precision-and-memory trade-offs that production systems (Cloudflare, Stripe, AWS) pick from.
- 13.4advanced
Trie autocomplete
Per-node ranked top-k cache, persistent suggestions across keystrokes, and the design moves that take a vanilla trie from O(L + answers) to single-digit-microsecond typeahead.
- 13.5advanced
Twitter feed design
LC 355 Design Twitter as a mechanics-driven design class: monotonic timestamps, per-user append-only logs, and a k-way merge through a heap of author cursors for the news feed.
- 13.6intermediate
Game state design
Store the answer the board would give, not the board itself. Per-row, per-column, per-diagonal counters give LC 348 Tic-Tac-Toe O(1) per move and O(n) memory total.