LeetCode Patterns: The 15 You Must Know
Master these 15 coding patterns and you can solve 90% of the problems that show up in real FAANG interviews. Stop grinding random problems. learn the patterns instead.
Quick Answer
The 10 LeetCode patterns that cover most FAANG interview questions: two pointers, sliding window, binary search on answer, BFS/DFS, DP (knapsack/LCS), merge intervals, monotonic stack, heap/priority queue, topological sort, and trie. Solve 100-150 problems deeply using the Blind 75 as a starting point. Pattern recognition, not memorization, is the skill being tested.
Why Patterns Beat Problem Memorization
There are over 3,000 problems on LeetCode. You cannot memorize them all, and you shouldn't try. What you can do is recognize that most problems are variations on a small set of underlying patterns. Once you see that a problem is a sliding window problem, the solution structure becomes clear even if you've never seen that exact problem before.
Pattern recognition is also more robust under interview pressure. When you're nervous, recall breaks down - but pattern matching is more automatic. Training yourself to identify the pattern first, then apply the template, is the professional way to prepare.
The 15 Core Patterns
1. Two Pointers
Use when working with sorted arrays or when you need to find pairs/triplets. Classic problems: 3Sum, Container With Most Water, Trapping Rain Water.
2. Sliding Window
Use for finding subarrays/substrings that satisfy a condition. Look for 'contiguous subarray' or 'substring' in the problem. Classic: Longest Substring Without Repeating Characters, Minimum Window Substring.
3. Fast & Slow Pointers
Use for linked list cycle detection, finding middle nodes, or palindrome checking. The tortoise and hare algorithm. Classic: Linked List Cycle, Happy Number.
4. Binary Search
Beyond sorted arrays. use when the search space is monotonic. If you can ask 'can I achieve X?' and the answer transitions from yes to no (or no to yes), binary search applies. Classic: Search in Rotated Array, Capacity to Ship Packages.
5. BFS (Breadth-First Search)
Use for shortest paths in unweighted graphs, level-order traversals, or finding minimum steps. Classic: Binary Tree Level Order Traversal, Word Ladder, Rotting Oranges.
6. DFS (Depth-First Search)
Use for exploring all paths, backtracking, connected components, and tree traversals. Classic: Number of Islands, Course Schedule, Path Sum.
7. Dynamic Programming
The hardest pattern to master. Look for: overlapping subproblems and optimal substructure. Break into 1D DP, 2D DP, and interval DP. Classic: Coin Change, Longest Common Subsequence, Edit Distance.
8. Merge Intervals
Use when given a list of intervals and asked to merge, insert, or check for overlap. Classic: Merge Intervals, Insert Interval, Meeting Rooms.
9. Cyclic Sort
Use when given a range 1 to N and asked to find missing/duplicate numbers. O(n) time, O(1) space. Classic: Find Missing Number, Find Duplicate.
10. In-place Reversal of Linked List
Use for reversing linked lists or sublists. Classic: Reverse Linked List, Reverse Nodes in k-Group.
11. Tree BFS / DFS
Level-order traversal = BFS. Path problems, root-to-leaf = DFS. Know both recursively and iteratively. Classic: Maximum Depth, Zigzag Level Order, Path Sum III.
12. Heap / Priority Queue
Use when repeatedly finding min or max. Two heaps pattern for median finding. Classic: Kth Largest Element, Find Median from Data Stream, Task Scheduler.
13. Monotonic Stack
Use for next greater/smaller element problems and histogram-type problems. Classic: Daily Temperatures, Largest Rectangle in Histogram, Next Greater Element.
14. Union-Find (Disjoint Set)
Use for connectivity problems, detecting cycles in undirected graphs. Classic: Number of Connected Components, Redundant Connection, Accounts Merge.
15. Trie (Prefix Tree)
Use for prefix-based search, autocomplete, and word dictionaries. Classic: Implement Trie, Word Search II, Design Add and Search Words.
How to Use This in Your Prep
Don't try to cover all 15 patterns at once. Spend a full week on a single pattern: watch one explanation video, solve 3 easy problems to understand the template, then solve 5–8 medium problems to internalize variations. By the end of the week you should be able to identify the pattern in under 30 seconds and write the solution structure without thinking.
Then combine this with company-specific frequency data. If you're targeting a company that asks a lot of dynamic programming problems, spend two weeks on DP variants instead of one. If the company leans toward graph problems, prioritize BFS/DFS/Union-Find. Real interview data from LeakCode gives you this calibration signal.
The "Pattern Recognition" Skill
The differentiator between candidates who finish their interview problem in 25 minutes and candidates who finish in 45 is pattern recognition speed, not coding speed. Strong candidates identify the right pattern within 60-90 seconds of reading the problem. Weak candidates spend 5-10 minutes pattern-matching before they start.
Train this skill explicitly: after solving each problem, write down what pattern it was (sliding window, two-pointer, BFS, memoized recursion, etc.) and what cue phrases triggered the recognition ("longest contiguous range", "shortest path", "find all ways to..."). Build a personal lookup table from cue phrases to patterns. After 100-200 problems, the lookup becomes automatic and your time-to-pattern drops below 60 seconds.
Pattern Frequency by Company
Based on 51,000+ candidate reports on LeakCode, coding round pattern distribution by company in 2024-2026 shows real differences. Google skews trees and graph (31%), dynamic programming (24%). Meta skews arrays and hash maps (28%), trees (22%). Amazon skews strings and sliding window (26%), arrays (21%).
OpenAI is the outlier: graph and DP combined account for 38% of reported coding rounds, with hard difficulty appearing more often than mediums. Anthropic and Mistral skew toward ML-systems problems that do not fit traditional LeetCode patterns at all. Calibrate your pattern allocation to your target company; do not split time evenly across all patterns.
Hidden Patterns Less Frequently Taught
Beyond the standard patterns, a few less-taught categories appear regularly in 2026 reports. Monotonic stack (next greater element, daily temperatures, largest rectangle in histogram): appears in 4-6% of Meta and Amazon reports. Difference array (range update, range query): appears in 3-5% of reports. Reservoir sampling (random sample from stream): appears in 2-3% of Google senior+ reports.
Knowing these less-common patterns has high marginal value because most candidates do not know them. Spending one week on the 3-4 less-taught patterns at the end of your prep produces disproportionate signal. Reports on LeakCode show candidates who recognize a monotonic-stack problem within 60 seconds score materially higher than candidates who solve it but take 3-5 minutes to identify the pattern.
Find the Highest-Frequency Coding Questions at Your Target Company
Real interview reports from 10+ sources, ranked by how often each question appears.
Browse by Company