The 14 LeetCode Patterns You Need in 2026
The core algorithmic patterns that appear in 90% of coding interviews — what they are, when to use them, and how to recognize them.
Why patterns matter more than problem count
There are over 3,000 problems on LeetCode. No one is solving all of them. The candidates who pass FAANG interviews consistently are not the ones who solved the most problems — they are the ones who recognize patterns quickly. Once you know the 14 core LeetCode patterns, most interview problems become variations of something you have already solved.
These LeetCode patterns for 2026 remain the foundation of technical interviews at every major company. Master these and you can handle the vast majority of coding interview questions.
The patterns
1. Two Pointers
Use when working with sorted arrays or linked lists and you need to find pairs or compare elements. One pointer starts at the beginning, another at the end (or both move forward at different speeds). Classic problems: two sum on a sorted array, container with most water, remove duplicates.
2. Sliding Window
Use when you need to find a subarray or substring that satisfies a condition. Maintain a window that expands and contracts. The key insight is recognizing when adding an element makes the window invalid and you need to shrink. Classic problems: longest substring without repeating characters, minimum window substring.
3. Fast and Slow Pointers
Use for cycle detection in linked lists or arrays. The fast pointer moves twice as fast as the slow pointer. If there is a cycle, they will meet. Also used for finding the middle of a linked list. Classic problems: linked list cycle, happy number.
4. Merge Intervals
Use when dealing with overlapping intervals. Sort by start time, then iterate and merge overlapping intervals. The pattern extends to insert interval, meeting rooms, and interval list intersections.
5. Cyclic Sort
Use when given an array containing numbers in a given range (1 to n). Place each number at its correct index. After sorting, any number not at its correct position reveals the missing or duplicate number. Classic problems: find all missing numbers, find the duplicate number.
6. In-Place Reversal of Linked List
Use when you need to reverse a linked list or a portion of it. Track three pointers: previous, current, and next. This pattern is the basis for reversing sublists, rotating lists, and alternating merge operations.
7. Tree BFS (Breadth-First Search)
Use for level-by-level tree traversal. Use a queue and process nodes level by level. The pattern applies to level order traversal, zigzag traversal, finding minimum depth, and right side view of a binary tree.
8. Tree DFS (Depth-First Search)
Use when you need to traverse all paths or search for a specific condition in a tree. Can be implemented recursively or with a stack. The three variants — preorder, inorder, postorder — each have specific use cases. Classic problems: path sum, diameter of binary tree, validate BST.
9. Two Heaps
Use when you need to find the median of a stream or partition elements into two groups. Maintain a max-heap for the smaller half and a min-heap for the larger half. The median is always at the top of one or both heaps. Classic problem: find median from data stream.
10. Subsets / Backtracking
Use for generating all combinations, permutations, or subsets. Build solutions incrementally and backtrack when a partial solution cannot lead to a valid complete solution. Classic problems: subsets, permutations, combination sum, N-queens.
11. Modified Binary Search
Use when searching in a sorted or partially sorted array. The key is adjusting the standard binary search for variations — rotated arrays, finding boundaries, or searching in an infinite array. Classic problems: search in rotated sorted array, find first and last position.
12. Top K Elements
Use when you need the K largest, smallest, or most frequent elements. A heap of size K gives you O(n log K) performance. QuickSelect gives O(n) average case. Classic problems: K closest points to origin, top K frequent elements.
13. K-Way Merge
Use when merging K sorted lists or arrays. Use a min-heap to efficiently track the smallest element across all lists. Classic problems: merge K sorted lists, smallest range covering elements from K lists.
14. Dynamic Programming
Use when the problem has overlapping subproblems and optimal substructure. The two approaches are top-down (memoization) and bottom-up (tabulation). Recognizing that a problem requires DP is the hardest part — look for "minimum/maximum," "count the number of ways," or "is it possible to" in the problem statement.
How to study these patterns
Do not try to learn all 14 patterns at once. Pick one pattern, solve 5 to 8 problems using that pattern until you can recognize it instantly, then move to the next. The goal is not to memorize solutions — it is to build the instinct that says "this is a sliding window problem" within the first 30 seconds of reading a new question.
Tools like Phantom Coder accelerate this process by showing you the optimal pattern for a problem in real time. Instead of spending 30 minutes on a wrong approach, you see the right pattern immediately and can focus on understanding why it works and how to implement it.
Ready to ace your next interview?
Phantom Coder gives you real-time AI assistance, invisible to screen sharing.
Download for macOS — $99/mo