DSA Master › Topic 18
Advanced Data Structures & Design
Design problems ask you to build a class that meets specific time bounds per operation. Usually that means combining two structures: a hash map for O(1) lookup, plus a linked list, heap or TreeMap for ordering.
Concepts
- HashMap + doubly linked list
- Heaps
- Ordered sets (TreeMap)
- Custom data structures
- Amortized complexity
How to recognise it
- The problem says "Implement a class with these methods in O(1) or O(log n)".
- You need recency (LRU) or frequency (LFU) ordering.
- There's a timestamp lookup (TreeMap floorKey) or weighted random sampling.
Common pitfalls
- Interviewers often want LRU built by hand with a HashMap and a doubly linked list.
- List each operation's required complexity before you choose structures.
Problems
- LRU Cache (Medium)
- LFU Cache (Hard)
- Implement Stack using Queues (Easy)
- Time Based Key-Value Store (Medium)
- Design Twitter (Medium)
- Random Pick with Weight (Medium)
- Insert Delete GetRandom O(1) – Duplicates Allowed (Hard)
- Design Circular Queue (Medium)
- Maximum Frequency Stack (Hard)
- Design a Food Rating System (Medium)