Coding · 9 min
Top 12 LeetCode Patterns for 2026 Interviews
The 12 patterns that dominate 80% of LeetCode questions. Master these and cut your solve time in half.
After reviewing thousands of FAANG interviews, the 12 dominant patterns are consistent. You don't need to grind 500 LeetCode — you need to recognize fast which pattern each problem belongs to and apply the right template. Here are the 12, in order of real-interview frequency.
1. Two Pointers — O(n)
Two pointers traversing the array from opposite ends or same direction. Ideal for: Two Sum sorted, 3Sum, palindrome check, container with most water. Template: while (left < right) { ... move left or right }. Mental attack: 'sorted array + find pair/triplet'.
2. Sliding Window — O(n)
Movable window that expands and contracts over the array. For: longest substring without repeating, minimum window substring, max sum subarray of size k. Template: expand right, shrink left when invalid. Mental: 'contiguous subarray with condition'.
3. Fast & Slow Pointers — O(n)
Tortoise & hare. For: linked list cycle, middle of list, palindrome list. Slow moves 1, fast moves 2. If they meet, there's a cycle. Mental: 'linked list + cycle or middle'.
4. Merge Intervals — O(n log n)
Sort by start and merge overlaps. For: merge intervals, insert interval, meeting rooms. Template: sort, then iterate and merge on overlap. Mental: 'intervals on a timeline'.
5. Cyclic Sort — O(n)
For arrays with numbers 1..n where you can use the index as expected position. For: missing number, find duplicates, smallest missing positive. Mental: 'numbers in range 1..n'.
6. In-place Reversal of Linked List — O(n)
Reverse linked list without extra space. For: reverse list, reverse sublist, reverse k group. Template: prev, curr, next pointers. Mental: 'linked list + reverse'.
7. BFS — O(V + E)
Breadth-first search on trees and graphs with queue. For: level order traversal, shortest path unweighted, minimum depth. Mental: 'shortest path or level-by-level'.
8. DFS — O(V + E)
Depth-first search with stack or recursion. For: tree paths, connected components, cycle detection. Mental: 'all paths or deep explore'.
9. Backtracking — O(branches^depth)
For: permutations, combinations, subsets, sudoku, N-queens. Template: add → recurse → remove. Mental: 'all possible combinations'.
10. Dynamic Programming — varies
Top-down memoization or bottom-up tabulation. For: knapsack, LIS, edit distance, coin change. Mental: 'overlapping subproblems'. Identify the subproblem and recurrence.
11. Heap / Priority Queue — O(n log k)
Min-heap or max-heap for top-K. For: top K frequent, K closest points, merge K sorted lists, median of stream. Mental: 'top-K or stream with median'.
12. Topological Sort — O(V + E)
For directed acyclic graphs (DAG). For: course schedule, task scheduling, build order. Kahn's algorithm with queue. Mental: 'dependencies + order'.
Key takeaway
Memorize the 12 patterns, not the 500 problems. With Darknote.ai you can OCR the problem and the AI auto-detects the pattern in under 2 seconds.