| Two pointers | Sorted array, pair search, partitioning | O(n) after sorting or per fixed index | - | Watch pointer movement invariants and duplicate skipping. |
| Sort + fixed index + two pointers | Unique triplets, 3Sum-style pair search after choosing one value | O(n^2) | 3Sum | Sort, skip duplicate fixed values, then move inward based on sum. |
| Sliding window | Contiguous subarray or substring | O(n) | - | Track what makes a window valid. |
| Hash map complement lookup | Pair sum or "find prior value that completes current value" | O(n) | Two Sum | Check for the complement before inserting the current value to avoid reusing the same index. |
| Hash map counting | Frequency, lookup, deduplication | O(n) | - | Clarify collision and memory trade-offs if asked. |
| Stack matching | Parentheses, nested structures, last-open-first-close validation | O(n) | Valid Parentheses | Push opening items, match closing items against the latest opening item. |
| Stack cancellation | Adjacent duplicate removal, collision-style cancellation, cleaned prefix tracking | O(n) | Remove All Adjacent Duplicates In String | The stack top is the latest kept item; pop it when the current item cancels it. |
| Monotonic stack | Next greater or next smaller value, span, waiting time | O(n) | Daily Temperatures | Store unresolved indices; pop when the current value resolves the top. |
| Sort intervals + scan | Merge intervals, meeting rooms, overlap detection | O(n log n) | Merge Intervals | Sort by start, then compare each interval with the last merged interval. |
| Track minimum so far | Single buy/sell profit, best difference with ordering constraint | O(n) | Best Time to Buy and Sell Stock | Keep the best prior buy price, then compute the profit if selling at the current value. |
| Greedy positive differences | Unlimited buy/sell, accumulate all local gains | O(n) | Best Time to Buy and Sell Stock II | If every positive edge can be captured independently, summing local gains equals the best global profit. |
| Greedy farthest reach | Jump Game, reachability over arrays, minimum jumps variants | O(n) | Jump Game | Track the farthest index reachable so far; an index beyond that boundary is unreachable. |
| Recursive tree comparison | Binary tree equality, symmetry, subtree checks | O(n) | Same Tree | Handle null cases first, then compare values and recurse into matching child branches. |
| DFS path building | Root-to-leaf paths, traversal with accumulated state | O(n) | Binary Tree Paths | Carry the path or state through recursion, then save it when the target condition is reached. |
| Prefix sum balance | Left/right balance, running totals, pivot checks | O(n) | Find Pivot Index | Keep a running left sum and derive the right side from the total. |
| Prefix sum counts | Count subarrays with a target sum, especially with negatives or zeroes | O(n) | Subarray Sum Equals K | Count earlier prefix sums that equal currentPrefix - k; initialize 0 -> 1. |
| BFS | Shortest path in unweighted graph | O(V + E) | - | Use queue and visited set. |
| DFS | Traversal, components, recursion | O(V + E) | - | Watch recursion depth. |
| Dynamic programming | Overlapping subproblems | Varies | - | Define state, transition, base cases. |