Design Data Structures problems, grouped by pattern
Design problems ask you to build a class with fast operations. The skill is choosing the right trade-off: pre-compute on insert or on query, and pick a structure that makes every operation fit the target complexity.
When to reach for it
- Implement a class with several methods
- Each method has a complexity target
- A standard structure needs one extra operation
Mistakes to watch for
- Forgetting to keep auxiliary structures in sync
- O(n) operations hiding in a method meant to be O(1)
- Edge cases on empty structures
The 36 problems
1Pre-processing + tradeoffs
- Design Neighbor Sum Service Animated Easy
- Simple Bank System Medium
- Design File System Medium
- Design HashMap Easy
- Dot Product of Two Sparse Vectors Medium
- Shortest Word Distance II Medium
- Flatten 2D Vector Medium
- Design Log Storage System Medium
- Range Sum Query - Mutable Medium
- Design HashSet Easy
- Design A Leaderboard Medium
- Design Tic-Tac-Toe Medium
2Linked Lists
- Design Linked List Animated Medium
- Design Front Middle Back Queue Animated Medium
- LRU Cache Medium
- All O`one Data Structure Hard
- LFU Cache Hard
3Stack
- Min Stack Animated Medium
- Design a Stack With Increment Operation Animated Medium
- Maximum Frequency Stack Animated Hard
- Max Stack Hard
- Flatten Nested List Iterator Medium
4Queue / Circular Buffer
- Design Hit Counter Medium
- Design Circular Queue Medium
- First Unique Number Medium
- Design Snake Game Medium
- Moving Average from Data Stream Easy
5Hash Map + Array
6Hash Map + Heap
- Cache With Time Limit Medium
7Randomized Algorithms
- Shuffle an Array Medium
8Dependency Graph
9Concurrency
10Simulation
- Design Memory Allocator Medium