Leetcode Category in Infrastructure
Classical Data Structures#
| Data Structure | Title & Question Number | Key Concept / Focus |
|---|---|---|
| Hash Table | #146 LRU Cache | Infra Essential: HashMaps + Doubly Linked Lists for O(1) access/eviction. |
| Hash Table | #460 LFU Cache | Advanced eviction policy; frequency-based tracking with nested HashMaps. |
| Array | #1 Two Sum | The foundation of frequency mapping and index lookups. |
| Array | #238 Product of Array Except Self | Prefix/suffix products without division; common in metric normalization. |
| String | #3 Longest Substring Without Repeating Characters | Mastering the Sliding Window pattern. |
| String | #49 Group Anagrams | Hashing and grouping; applicable to log deduplication and fingerprinting. |
| Linked List | #206 Reverse Linked List | Core pointer manipulation and iterative/recursive logic. |
| Linked List | #23 Merge K Sorted Lists | Heap-based merging; mirrors merging sorted log streams from multiple sources. |
| Stack | #20 Valid Parentheses | Linear parsing and LIFO (Last-In-First-Out) logic. |
| Stack | #84 Largest Rectangle in Histogram | Monotonic stack; useful for capacity planning and resource window analysis. |
| Queue | #239 Sliding Window Maximum | Monotonic Queue for optimized window processing. |
| Queue | #933 Number of Recent Calls | Rate limiting simulation; directly models request throttling logic. |
| Tree | #102 Binary Tree Level Order Traversal | The “Hello World” of Breadth-First Search (BFS). |
| Tree | #236 Lowest Common Ancestor of a Binary Tree | Recursive tree traversal; models namespace/path hierarchy resolution. |
| BST | #98 Validate Binary Search Tree | Understanding recursion boundaries and tree properties. |
| BST | #230 Kth Smallest Element in a BST | In-order traversal; useful for percentile queries on ordered metrics. |
| Heap | #215 Kth Largest Element in an Array | Efficiently managing “Top K” streaming data or task priority. |
| Heap | #295 Find Median from Data Stream | Dual-heap pattern; real-time percentile tracking (p50/p99 latency). |
| Graph | #200 Number of Islands | Matrix traversal using DFS/BFS; the most common graph prompt. |
| Graph | #133 Clone Graph | BFS/DFS with memoization; models deep-copying distributed config graphs. |
| Trie | #208 Implement Trie (Prefix Tree) | Efficient string prefix storage and autocomplete logic. |
| Trie | #212 Word Search II | Trie + DFS backtracking; models multi-pattern log/path matching. |
| Union-Find | #547 Number of Provinces | Infra Essential: Models network partition detection and cluster connectivity. |
| Union-Find | #684 Redundant Connection | Cycle detection in graphs; identifies redundant links in network topology. |
Classical Algorithms#
| Algorithm Category | Title & Question Number | Real-World Context (Infra/SRE) |
|---|---|---|
| Binary Search | #33 Search in Rotated Sorted Array | Searching through partitioned or sharded sorted data sets. |
| Binary Search | #153 Find Minimum in Rotated Sorted Array | Efficiently locating boundaries in rotated/partitioned data. |
| BFS (Graph) | #127 Word Ladder | Finding the shortest path in an unweighted state-space/network. |
| BFS (Graph) | #994 Rotting Oranges | Multi-source BFS; models failure/alert propagation across a network. |
| DFS (Graph) | #207 Course Schedule | Topological Sort: Resolving service or package dependencies. |
| DFS (Graph) | #399 Evaluate Division | Weighted graph traversal; models unit conversion chains and metric ratios. |
| Dijkstra | #743 Network Delay Time | Directly mirrors network packet routing and latency calculations. |
| Dijkstra | #787 Cheapest Flights Within K Stops | Constrained shortest path; models cost-aware routing with hop limits. |
| Two Pointers | #15 3Sum | Optimizing multi-variable searches from O(n³) to O(n²). |
| Two Pointers | #11 Container With Most Water | Greedy boundary shrinking; models capacity optimization problems. |
| Sliding Window | #76 Minimum Window Substring | Extracting specific patterns from high-velocity log streams. |
| Sliding Window | #438 Find All Anagrams in a String | Fixed-size window pattern matching; applicable to network signature detection. |
| Backtracking | #46 Permutations | Exhaustive state-space search (e.g., finding all possible config combinations). |
| Backtracking | #79 Word Search | DFS + backtracking on a grid; models path finding in topology graphs. |
| Greedy | #435 Non-overlapping Intervals | Infra Essential: Scheduling maintenance windows and minimizing overlapping deploys. |
| Greedy | #55 Jump Game | Local decision-making to reach a global destination efficiently. |
| DP (1D) | #322 Coin Change | Optimization problems like fitting tasks into fixed-size nodes. |
| DP (1D) | #300 Longest Increasing Subsequence | Modeling monotonically growing metrics; version ordering. |
| DP (2D) | #1143 Longest Common Subsequence | Underlying logic for diff tools and version control comparisons. |
| DP (2D) | #72 Edit Distance | Minimum edit operations; powers fuzzy log matching and config drift detection. |
| Bit Manipulation | #191 Number of 1 Bits | Low-level performance tuning and flag-based state management. |
| Bit Manipulation | #136 Single Number | XOR-based deduplication; detecting unique anomalies in paired datasets. |
Infra System Design in Code#
Storage Systems#
| # | Problem | Infra Scenario |
|---|---|---|
| 588 | Design In-Memory File System | File system (mkdir, ls, read, write) |
| 1166 | Design File System | Hierarchical key-value storage |
| 981 | Time Based Key-Value Store | Versioned KV store (like MVCC) |
| 1146 | Snapshot Array | Copy-on-write / snapshot semantics |
| 635 | Design Log Storage System | Log storage with timestamp range queries |
| 706 | Design HashMap | Core KV store — hashing, collision resolution |
| 2502 | Design Memory Allocator | alloc(size) / free(id) — memory allocator |
Scheduling / Task Systems#
| # | Problem | Infra Scenario |
|---|---|---|
| 621 | Task Scheduler | CPU scheduling with cooldown |
| 1834 | Single-Threaded CPU | Single-threaded job queue with priority |
| 1882 | Process Tasks Using Servers | Weighted load-balanced task queue |
| 253 | Meeting Rooms II | Minimum resources for overlapping jobs |
Caching / Eviction#
| # | Problem | Infra Scenario |
|---|---|---|
| 146 | LRU Cache | LRU eviction (Redis, Memcached) |
| 460 | LFU Cache | Frequency-based eviction |
| 1797 | Design Authentication Manager | Token lifecycle with TTL expiration |
Monitoring / Metrics / Rate Limiting#
| # | Problem | Infra Scenario |
|---|---|---|
| 362 | Design Hit Counter | QPS tracking, sliding window counter |
| 359 | Logger Rate Limiter | Log throttling / deduplication |
| 295 | Find Median from Data Stream | Real-time P50/P99 latency |
| 346 | Moving Average from Data Stream | Rolling average (CPU, latency) |
| 1825 | Finding MK Average | Trimmed mean (remove outliers) |
| 933 | Number of Recent Calls | Fixed-window rate counter |
| 2034 | Stock Price Fluctuation | Live min/max/current dashboard |
Message Queues / Streaming#
| # | Problem | Infra Scenario |
|---|---|---|
| 1188 | Design Bounded Blocking Queue | Producer-consumer with backpressure |
| 622 | Design Circular Queue | Ring buffer (Kafka, Disruptor internals) |
| 641 | Design Circular Deque | Work-stealing queue |
| 1656 | Design an Ordered Stream | In-order delivery from out-of-order stream (TCP reassembly) |
| 352 | Data Stream as Disjoint Intervals | Stream compaction / range merging |
Concurrency#
| # | Problem | Infra Scenario |
|---|---|---|
| 1114 | Print in Order | Sequential pipeline stages |
| 1115 | Print FooBar Alternately | Producer-consumer sync |
| 1117 | Building H2O | Barrier synchronization |
| 1226 | The Dining Philosophers | Deadlock avoidance |
| 1242 | Web Crawler Multithreaded | Concurrent worker pool |
| 1279 | Traffic Light Controlled Intersection | Mutual exclusion |
Search / Indexing#
| # | Problem | Infra Scenario |
|---|---|---|
| 642 | Design Search Autocomplete System | Typeahead / autocomplete |
| 211 | Design Add and Search Words | Wildcard pattern matching in indexes |
| 208 | Implement Trie | Core prefix index structure |
Infra Data Structures#
| # | Problem | Infra Scenario |
|---|---|---|
| 1206 | Design Skiplist | LevelDB/RocksDB memtable, Redis sorted set |
| 380 | Insert Delete GetRandom O(1) | Consistent hashing node selection |
| 432 | All O(1) Data Structure | Real-time metric tracking |
| 855 | Exam Room | Uniform distribution / consistent hashing |
| 895 | Maximum Frequency Stack | Hot-key detection in caching |
Resource Management#
| # | Problem | Infra Scenario |
|---|---|---|
| 379 | Design Phone Directory | Connection pool / ID allocator |
| 355 | Design Twitter | Multi-resource system (users, feeds, fan-out) |
| 1797 | Design Authentication Manager | Session management with TTL |
Priority#
Tier 1 (Must do):
├── 146 LRU Cache
├── 588 In-Memory File System
├── 981 Time Based Key-Value Store
├── 1188 Bounded Blocking Queue
├── 362 Hit Counter
├── 621 Task Scheduler
└── 1206 Design Skiplist
Tier 2 (High value):
├── 460 LFU Cache
├── 2502 Memory Allocator
├── 1242 Web Crawler Multithreaded
├── 295 Median from Data Stream
├── 642 Search Autocomplete
├── 359 Logger Rate Limiter
└── 1656 Ordered Stream
Tier 3 (Nice to have):
├── 355 Design Twitter
├── 1226 Dining Philosophers
├── 1146 Snapshot Array
├── 635 Log Storage System
└── 432 All O(1) Data Structure
Read other posts