Technical Prep

The 15 LeetCode Patterns Every FAANG Candidate Should Know

By Hari January 4, 2026
The 15 LeetCode Patterns Every FAANG Candidate Should Know

The BLS projects 129,200 software developer job openings per year through 2034, yet most candidates I talk to are still grinding problems in random order and wondering why they blank on problems they’ve seen before. Pattern recognition is the difference. Once you can look at a problem and say “that’s a sliding window” within 30 seconds, you stop solving problems one at a time and start solving categories.

The 15 patterns below cover most of what shows up at Google, Meta, Amazon, and similar companies. I’m not claiming the list is exhaustive, and I don’t know how well it transfers outside standard SWE coding rounds. But for a structured algorithm screen, this is where to start. The Tech Interview Handbook (by ex-Meta Staff Engineer Yangshun Tay) and NeetCode’s 150-problem list organize prep around roughly the same patterns, a reasonable signal the list is stable.

The 15 patterns, with when to use each

1. Two Pointers

Use this on sorted arrays, or any time you’re searching for pairs or need to partition in-place. Two pointers moving toward each other collapses an O(n²) nested loop into a single O(n) pass. Classic trigger: the problem mentions “sorted array” and asks for pairs summing to a target.

Practice: Two Sum II, 3Sum, Container With Most Water, Trapping Rain Water.

2. Sliding Window

Any time you see “contiguous subarray” or “consecutive elements,” think sliding window first. You expand the right edge to include elements, shrink the left edge when a constraint is violated, and track state across the window rather than recomputing it.

Practice: Longest Substring Without Repeating Characters, Minimum Window Substring, Sliding Window Maximum.

3. Fast and Slow Pointers

Cycle detection in linked lists is the canonical use case. Slow pointer moves one step; fast pointer moves two. They’ll eventually meet if a cycle exists. Also useful for finding the middle of a linked list in one pass without counting the length first.

Practice: Linked List Cycle, Find the Duplicate Number, Happy Number.

4. Merge Intervals

Sort by start time, then iterate and merge whenever the current interval’s start is less than or equal to the previous interval’s end. The sort is O(n log n); the merge is O(n). Most interval problems collapse into this pattern once you see the structure.

Practice: Merge Intervals, Insert Interval, Non-overlapping Intervals, Meeting Rooms II.

5. Binary Search

Sorted arrays are the obvious case, but the real trigger is: “can I define a monotonic condition?” If you can say “everything left of some boundary is false, everything right is true,” binary search applies. This covers finding boundaries, minimum valid values, and search in rotated arrays.

Practice: Binary Search, Search in Rotated Sorted Array, Find First and Last Position, Koko Eating Bananas.

6. BFS (Breadth-First Search)

Shortest path in an unweighted graph. Level-order traversal. “Minimum steps to reach X.” You need a queue. Process level by level. The first time you reach a node is guaranteed to be the shortest path. BFS doesn’t help for weighted graphs.

Practice: Binary Tree Level Order Traversal, Rotting Oranges, Word Ladder, Shortest Path in Binary Matrix.

7. DFS (Depth-First Search)

Exploring all paths, connected components, tree traversals, detecting cycles in directed graphs. Use recursion or an explicit stack. Mark visited nodes to avoid infinite loops. If BFS is “find the fastest route,” DFS is “find every route and report.”

Practice: Number of Islands, Clone Graph, Path Sum, Course Schedule.

8. Backtracking

Anything asking for “all combinations,” “all permutations,” or “generate all possible X.” Make a choice, recurse, then undo the choice. Prune early to avoid exploring invalid branches. The undo step is what distinguishes backtracking from plain DFS.

Practice: Subsets, Permutations, Combination Sum, N-Queens, Sudoku Solver.

9. Dynamic Programming

Optimization (find the min or max) or counting ways, where subproblems overlap. The hard part is defining the state clearly before writing any code. Once you have the state and the recurrence relation, the implementation is often short. I’d argue DP is the pattern most candidates underinvest in, because it’s uncomfortable, and skip to graph problems instead. That’s probably a mistake.

Practice: Climbing Stairs, House Robber, Coin Change, Longest Common Subsequence, 0/1 Knapsack.

10. Topological Sort

Dependency ordering in a directed acyclic graph. Task scheduling. Build order. Use Kahn’s algorithm (BFS on in-degrees) or DFS post-order. If you detect a cycle during topological sort, there’s no valid ordering.

Practice: Course Schedule I and II, Alien Dictionary, Task Scheduler.

11. Heap / Priority Queue

Finding the k-th largest, k-th smallest, or running medians. Min-heap to track the k largest elements seen so far (pop when size exceeds k). Max-heap for the k smallest. Heap operations cost O(log n), so k-element solutions run in O(n log k), which is much better than sorting the whole array for large inputs.

Practice: Kth Largest Element in an Array, Merge K Sorted Lists, Top K Frequent Elements, Find Median from Data Stream.

12. Union Find

Connected components in undirected graphs, cycle detection without a visited set, grouping elements into disjoint sets. Path compression plus union by rank brings individual operations to nearly O(1) amortized. Underused pattern in interview prep; shows up more than you’d expect.

Practice: Number of Connected Components, Redundant Connection, Accounts Merge.

13. Trie

Prefix matching, autocomplete, or any problem where you need to search a dictionary of words by prefix. Each node is a character. Paths from the root form prefixes. Tries make prefix lookups O(m) where m is the length of the prefix, vs. O(n * m) for iterating over a list.

Practice: Implement Trie, Word Search II, Design Add and Search Words, Replace Words.

14. Monotonic Stack

“Next greater element,” “previous smaller element,” histogram problems. You keep the stack in sorted order and pop elements that violate the invariant. It looks counterintuitive the first time, but the pattern is consistent: iterate, pop until the invariant holds, push.

Practice: Daily Temperatures, Next Greater Element, Largest Rectangle in Histogram.

15. Bit Manipulation

XOR-based problems (find the missing number, find the single non-duplicate), power-of-two checks, counting set bits. These show up less frequently than DP or graphs, but when they do appear, candidates who don’t know the XOR trick get stuck fast. Worth one focused study session.

Practice: Single Number, Number of 1 Bits, Counting Bits, Missing Number, Power of Two.

A quick-reference trigger table

When you read a new problem, scan for these phrases first:

  • “Contiguous subarray” or “consecutive elements” → Sliding Window
  • “Sorted array” + “find pair” → Two Pointers
  • “Shortest path” (unweighted) → BFS
  • “All combinations” or “all permutations” → Backtracking
  • “Minimum” or “maximum” with overlapping subproblems → Dynamic Programming
  • “K largest” or “K smallest” → Heap
  • “Connected components” (undirected) → Union Find or DFS
  • “Dependency order” or “topological” → Topological Sort
  • “Prefix matching” or “autocomplete” → Trie
  • “Next greater element” → Monotonic Stack
  • “Cycle detection” → Fast and Slow Pointers or DFS with coloring

A study order that works

If you’ve got a few weeks, start with Two Pointers, Sliding Window, and Binary Search (best return early), then BFS, DFS, and Backtracking, then give Dynamic Programming a dedicated week because it builds on itself. Finish with Heap, Union Find, Trie, Topological Sort, Monotonic Stack, and Bit Manipulation. Three to five problems per pattern is the right range to build the recognition reflex. More than seven hits diminishing returns, at least in my experience.

What we see on LastRound AI

When candidates practice mock coding interviews on LastRound AI, the most common point of failure isn’t “I don’t know this algorithm.” It’s “I know the algorithm but I started coding before I identified the pattern.” Spending 3-4 minutes on pattern recognition before writing a single line is faster overall, but it requires deliberate practice to make it feel natural. That’s the habit the mock sessions are designed to build.

Pattern recognition is a skill, not just knowledge

Reading this list is not the same as being able to apply it in an interview. The gap between “I’ve seen this pattern before” and “I can implement it cleanly in 25 minutes while talking through my reasoning” is where most preparation falls short. That gap only closes with timed practice, with feedback.

Beyond coding rounds, the guide to passing coding interviews covers what to say and when, the FAANG interview questions breakdown for 2026 pairs well with this pattern list, and the system design interview guide covers the structural patterns in those rounds.

The patterns are stable; the formats around them change. Whether a 35-minute LeetCode screen is the best way to hire engineers is a fair question I don’t know the answer to. But it’s the current standard, and knowing these 15 patterns well beats grinding problems in random order.

Practice the patterns under real interview pressure

LastRound AI’s mock coding interviews let you practice applying these 15 patterns with timed sessions, live hints when you’re stuck, and feedback on your problem-solving approach.

Hari

Written by

Hari

Engineering, LastRound AI.

View Hari's LinkedIn profile →

Leave a Reply

Your email address will not be published. Required fields are marked *