ποΈ Design
Design problems test how you combine data structures. The trick is meeting time-complexity requirements on every operation simultaneously β usually by chaining a hash map with a doubly-linked list or heap.
This category contains 11 problems. Use the patterns below to recognize what's being asked, then jump to the problem list at the bottom.
π§ Key Patternsβ
- LRU Cache β Hash map + doubly-linked list for get & put.
- LFU Cache β Hash + frequency buckets (lists or heap).
- Iterator β Encapsulate state; provide
hasNext/nextlazily. - Range Sum (Immutable / Mutable / 2D) β Prefix sums, Fenwick tree, segment tree.
- Time-based Key-Value Store β Hash map β list, binary search on timestamps.
- Min Stack β Auxiliary stack of running mins.
β οΈ Common Pitfallsβ
- Forgetting the doubly-linked list β singly is for the remove step in LRU.
- Not clarifying complexity targets up front; over- or under-engineering.
π Study Resourcesβ
πΊ Videosβ
π Booksβ
- Designing Data-Intensive Applications β Kleppmann β For real-world scale (beyond LeetCode)
- Cracking the Coding Interview β Ch. 7 (OO Design), Ch. 9 (System Design)
π Articles & Referencesβ
π» All Design Problemsβ
Design Circular Queue
LeetCode 860 | Difficulty: Medium
Encode and Decode TinyURL
LeetCode 535 | Difficulty: Medium
Implement Queue using Stacks
LeetCode 232 | Difficulty: Easy
Implement Stack using Queues
LeetCode 225 | Difficulty: Easy
Logger Rate Limiter
LeetCode Link
LRU Cache
LeetCode 146 | Difficulty: Medium
Min Stack
LeetCode 155 | Difficulty: Medium
Moving Average from Data Stream
LeetCode Link
Range Sum Query - Immutable
LeetCode 303 | Difficulty: Easy
Range Sum Query - Mutable
LeetCode 307 | Difficulty: Medium
Range Sum Query 2D - Immutable
LeetCode 304 | Difficulty: Medium