-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy path00_DesignOverview.cpp
More file actions
70 lines (56 loc) · 2.47 KB
/
Copy path00_DesignOverview.cpp
File metadata and controls
70 lines (56 loc) · 2.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*
================================================================================
DESIGN DATA STRUCTURES - OVERVIEW
================================================================================
Design problems test your ability to:
1. Choose appropriate data structures
2. Achieve required time/space complexity
3. Handle edge cases
4. Write clean, maintainable code
Key Combinations:
- HashMap + Doubly Linked List → LRU Cache, LFU Cache
- HashMap + Array → Insert Delete GetRandom O(1)
- HashMap + Heap → Design Twitter, Top K
- Stack of Stacks → Min Stack
- Two Data Structures → Queue from Stacks
================================================================================
COMMON PATTERNS
================================================================================
1. CACHE DESIGNS
─────────────
LRU, LFU, TTL-based caches
Key: HashMap for O(1) access + ordering structure
2. RANDOM ACCESS IN O(1)
──────────────────────
Insert, Delete, GetRandom all O(1)
Key: Array + HashMap (swap with last on delete)
3. ITERATOR PATTERNS
──────────────────
Flatten structures, peek ahead, filter
Key: Stack for DFS-like iteration
4. TIME-BASED STRUCTURES
──────────────────────
Versioned data, time-range queries
Key: Binary search on timestamps
5. STREAM PROCESSING
──────────────────
Moving average, rate limiter, hit counter
Key: Queue with sliding window
================================================================================
FILE ORGANIZATION
================================================================================
01_CacheDesigns.cpp - LRU, LFU, TTL Cache
02_HashMapDesigns.cpp - HashMap, HashSet, RandomizedSet
03_StackQueueDesigns.cpp - Min Stack, Queue from Stacks
04_IteratorPatterns.cpp - Flatten, Peek, Zigzag iterators
05_TimeBasedDesigns.cpp - Snapshot Array, Time Key-Value Store
06_AdvancedDesigns.cpp - Twitter, Browser History, Skiplist
================================================================================
*/
#include <bits/stdc++.h>
using namespace std;
int main() {
cout << "=== Design Data Structures ===" << endl;
cout << "See individual files for implementations." << endl;
return 0;
}