Part 13 of 14

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
  1. 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.

    20 min
  2. 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.

    20 min
  3. 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.

    15 min
  4. 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.

    25 min
  5. 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.

    15 min
  6. 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.

    20 min
  7. 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.

    15 min