Pattern recognition + coding framework
Inputs, outputs, edge cases, constraints
Walk through 2-3 examples by hand
Identify pattern, state approach + complexity
Write clean, correct code
Trace through, edge cases, optimize
Access O(1) · Search O(n) · Insert O(n) Sequential data, index-based
Get/Set/Delete O(1) avg Count, lookup, dedup
Push/Pop O(1) Undo, parsing, DFS
Enq/Deq O(1) BFS, sliding window
Insert/Delete O(1) at pointer LRU cache, merge
Search/Insert O(log n) Ordered data, ranges
Insert O(log n) · ExtractMin O(log n) Top-K, median, priority
Depends on representation Networks, paths, cycles
When: Sorted array, pair sum
Two Sum II, 3Sum
When: Subarray/substring with condition
Max Subarray, Min Window Sub
When: Cycle detection, middle node
Linked List Cycle, Happy Number
When: Overlapping ranges
Merge Intervals, Insert Interval
When: Sorted input, min/max answer
Search Rotated, Koko Bananas
When: Shortest path, level order
Level Order, Rotten Oranges
When: Explore all paths, connected comp
Number of Islands, Path Sum
When: All combinations/permutations
Subsets, N-Queens, Word Search
When: Dependencies, ordering
Course Schedule, Alien Dict
When: Dynamic connectivity, groups
Connected Comp, Redundant Edge
When: Next greater/smaller element
Daily Temperatures, Histogram
When: Top-K, median, scheduling
Top K Frequent, Merge K Lists
When: Overlapping subproblems, optimal
Coin Change, LCS, Knapsack
When: Local optimal → global optimal
Jump Game, Activity Selection
When: Prefix matching, autocomplete
Word Search II, Implement Trie