PracHub
QuestionsCoachesLearningGuidesInterview Prep

15 Coding Patterns That Crack Any FAANG Interview

Learn the 15 coding interview patterns that still matter in 2026, with cues, costs, and LeetCode drills for faster problem recognition.

Author: PracHub

Published: 7/18/2026

Home›Knowledge Hub›15 Coding Patterns That Crack Any FAANG Interview

15 Coding Patterns That Crack Any FAANG Interview

By PracHub
July 18, 2026
0

Quick Overview

Learn the 15 coding interview patterns that still matter in 2026, including sliding window, two pointers, prefix sums, monotonic stacks, heaps, binary search, BFS, DFS, backtracking, topological sort, and dynamic programming. This guide explains the recognition cues, core moves, time and space costs, and LeetCode drills that help candidates solve problems by pattern instead of memorization.

Software EngineerFree

The recognition cues, the cost of each pattern, and which ones still show up in 2026 loops, with the stale ones cut and named.

(You don't need a key per lock. Fifteen patterns open most of the problems any loop will put in front of you; the grind is learning which key fits which door.)

I failed a candidate who had over 500 solved problems. One-hour screening interview, medium-difficulty problem. He recognized it out loud and told me he'd solved it months ago, and I had changed one constraint: return the indices instead of the values. That single edit erased his memorized solution, because the changed ask changed the pattern; the answer became a hash map. He burned forty minutes trying to reverse-engineer something he "knew." In the feedback form I wrote "strong memory, no recognition," and it's the most common sentence I write. The problem count was never the asset. Recognition is.

Strip away the noise, and every problem you face is one of about fifteen core shapes in a different disguise. Spot which one you're looking at inside the first minute, and the problem usually solves itself. That's the skill that survives a changed constraint: this input plus this ask means that pattern. Study the shapes, drill a few problems per pattern, and stop counting solves.

I didn't guess these. The fifteen came out of scraping LeetCode's raw frequency tags, then checking each tag against the onsite loops (the strung-together interview rounds) I've personally run since 2024. Cyclic sort sat on every 2019 list. Today it's nearly extinct, because nobody insists on the O(1)-space version anymore and a plain hash set answers the same questions. Monotonic stack and binary-search-on-the-answer were on none of them and now show up constantly. Lists age. This one states its date.

How Recognition Cues Work

A cue is your trigger. It's the moment you look at the shape of the data and know what trap the interviewer set for you. On its own, "sorted array" tells you almost nothing. "Sorted array, and they want a pair that sums to a target" says two pointers before you've finished reading. Train the pairing, and the cue starts finishing your sentence for you.

(Recognition in one picture: read the input shape and the ask, follow the arrow. In the first minute of an interview this flow is the entire job.)

This is your survival guide. We are stripping 15 patterns down to the bare metal: the trigger (Cue), the execution (Move), the time-and-memory tax (Cost), and the exact problems to drill (Drill). Read the cues twice as often as the code. The code doesn't matter if you build the wrong thing.

The 15 Cards

1) Sliding Window

  • Cue: contiguous substring or subarray, plus "longest," "shortest," or "count" under some rule.
  • Move: you set up a frame with two indexes. Push the right edge forward to eat more data, and snap the left edge forward the second your conditions are violated. Track the best window seen.
  • Cost: O(n) time, one clean pass. Space runs O(k), where k is however many unique elements you're tracking, usually just the character alphabet.
  • Drill: warm up on Longest Substring Without Repeating Characters (Medium), then Minimum Window Substring (Hard) once that stops hurting.

2) Two Pointers

  • Cue: sorted array, or a pair/triple that must meet a condition, or in-place partitioning.
  • Move: pinch the window. If your sum is too small, step the left pointer up. Too big? Step the right pointer down.
  • Cost: O(n) for pairs after sorting; triples like 3Sum wrap that walk in a loop, so O(n²). Space stays O(1).
  • Drill: 3Sum (Medium) first, Container With Most Water (Medium) right after.

3) Fast and Slow Pointers

  • Cue: a linked list, plus the words "cycle" or "middle," or a hard O(1) space limit.
  • Move: two pointers on the same track, one moving twice as fast. If there's a loop they meet, and when the fast one finishes, the slow one sits at the middle.
  • Cost: one O(n) pass at O(1) space, the whole board cleared without allocating a single extra byte.
  • Drill: Linked List Cycle (Easy), then Find the Duplicate Number (Medium), an array that secretly links to itself.

4) Prefix Sum + HashMap

  • Cue: "how many subarrays sum to K," or running-total questions over unsorted arrays where a window fails because of negative numbers.
  • Move: carry a running sum. Store how often each sum has appeared. At each step, look up running-sum-minus-K in the map. Think of this as Two Sum's older sibling. Instead of hunting for a static match, you are caching and hunting a running total, and it's the same hash map that solved my intro story.
  • Cost: O(n) time and an O(n) map.
  • Drill: Subarray Sum Equals K (Medium), with Contiguous Array (Medium) right behind it.

5) Merge Intervals

  • Cue: ranges with starts and ends: meetings, bookings, anything that can overlap.
  • Move: sort by start, walk once, merge whenever the current start falls inside the previous end.
  • Cost: the sort is your biggest tax at O(n log n). Worst case (zero overlaps), you also pay O(n) space to hold a perfect clone of the input.
  • Drill: Merge Intervals (Medium). Insert Interval (Medium) after, since sorted input lets you skip the sort.

6) In-place Linked List Reversal

  • Cue: reverse a list or part of one, without extra memory.
  • Move: walk the list with three pointers, previous, current, next, rewiring one arrow per step.
  • Cost: same bill as card 3, O(n) time against O(1) space. The entire mutation is one pass and those three pointers. Nothing more.
  • Drill: Reverse Linked List (Easy) until it's boring, then Reverse Nodes in k-Group (Hard).

7) Monotonic Stack

  • Cue: "next greater element," "days until warmer," spans, or largest rectangle under a histogram.
  • Move: keep a stack that only holds values in one order. Each new element pops everything it beats, and each pop answers that popped element's question.
  • Cost: O(n) both ways. Each element gets pushed once and popped once, and that's the whole bill. This is the big riser of the last few years; interviewers lean on it to filter out anyone who only memorized basic array moves.
  • Drill: Daily Temperatures (Medium) teaches it. Largest Rectangle in Histogram (Hard) makes you earn it.

8) Heap / Top-K

  • Cue: asked for the k of anything: "k largest," "k closest," "most frequent k," or a running best over a stream.
  • Move: keep a heap of size k. Push each element. Pop when the heap grows past k. What survives is the answer.
  • Cost: O(n log k) time and O(k) space, where k is the strict size cap of your heap. Make sure you explicitly say "log k, not log n" out loud. Interviewers are waiting to check that exact box on their grading rubric.
  • Drill: Kth Largest Element in an Array (Medium), and Top K Frequent Elements (Medium) to add the counting layer.

9) Modified Binary Search

  • Cue: sorted or rotated-sorted input, and a demand for O(log n).
  • Move: find the pivot first. One half of a rotated array is always strictly sorted, so identify the clean half and run standard binary search there.
  • Cost: O(log n) with nothing extra held, which was the assignment.
  • Drill: Search in Rotated Sorted Array (Medium). Find Minimum in Rotated Sorted Array (Medium) is the same idea with less noise.

10) Binary Search on the Answer

  • Cue: "minimum speed to finish in time," "smallest capacity to ship in D days," min-of-max and max-of-min asks.
  • Move: stop searching the array and search the answer space instead. Guess a value, check feasibility in O(n), halve accordingly.
  • Cost: the feasibility check costs O(n) and you run it about log(range) times.
  • Drill: Koko Eating Bananas (Medium) is the canonical one; Split Array Largest Sum (Hard) is the harder rep. This is the other riser, and the ultimate trap for grinders. Pure memorization will get you killed here.

11) BFS (tree and grid)

  • Cue: "level by level," "minimum steps," or the nearest one of something in an unweighted space.
  • Move: dump the starting nodes in a queue and process them in outward rings, pushing neighbors to the back of the line. Forget your visited set and you will infinite-loop your way right out of a job offer.
  • Cost: O(V+E) time. Space is O(V) with the visited set; the queue alone peaks at the widest level.
  • Drill: Binary Tree Level Order Traversal (Medium), plus Rotting Oranges (Medium) for the grid version.

12) DFS (tree and graph)

  • Cue: a tree or graph, and the ask is existence or everything: "any path," "all regions," answers that bubble up from children. If the ask is nearest, that's card 11's queue.
  • Move: recurse to the bottom, combine child answers on the way back up. For grid problems, flood-fill the neighbors and tag them as visited the exact millisecond you touch them.
  • Warning: forgetting your visited set on a graph traps you in an infinite loop.
  • Cost: O(V+E) time. Space is O(V) in graphs once you count the visited set; O(depth) stack on trees.
  • Drill: Number of Islands (Medium) covers grids; Path Sum II (Medium) covers trees.

13) Backtracking

  • Cue: "all combinations," "all permutations," "all valid arrangements," every option rather than the best one.
  • Move: choose, recurse, un-choose. The un-choose is the entire pattern, and forgetting it is the classic bug.
  • Cost: exponential, no way around it: O(2^n) subsets, O(n!) permutations. Admit that up front and prune what you can.
  • Drill: Subsets (Medium) teaches the skeleton; Word Search (Medium) bolts it onto a grid.

14) Topological Sort

  • Cue: tasks with prerequisites, build orders, "can these courses be finished."
  • Move: tally up your prerequisites (incoming edges). Push every node with zero dependencies into a queue. As you process and clear them, knock down the requirements for their neighbors. If your queue goes empty but nodes are left over? You've got a cycle.
  • Cost: O(V+E), plus one counter per node.
  • Drill: Course Schedule (Medium), and Course Schedule II (Medium), the same question asked a second way.

15) 1-D Dynamic Programming

  • Cue: you're choosing under a constraint, a budget, a no-two-adjacent rule, and the subproblems overlap. Listen for "maximum value under a limit," "count the ways," "can this be split."
  • Move: nail down the base cases first, then an array caching earlier answers, then the loop filling dp[i] from dp[i-1]. Can't state what dp[i] means in a single sentence? You don't have the recurrence yet.
  • Cost: O(n) for the linear family (House Robber), O(n × budget) for the knapsack family, with the space often rolled down to one row.
  • Drill: House Robber (Medium) for the linear form, Partition Equal Subset Sum (Medium) for the knapsack form. (DP gets a full article of its own next.)

The Cues on a Sticky Note

The six pairings you'll meet most often in a first round, small enough to glance at before the call connects:

The input + the askThe pattern
Contiguous subarray + best/countSliding window
Sorted + pair to targetTwo pointers
Next greater / spansMonotonic stack
K largest / most frequentHeap of size k
Minimum steps / level by levelBFS
Prerequisites / build orderTopological sort

The Cuts

The cuts, named so you can skip them with a clear conscience:

  • Cyclic sort: interviewers stopped demanding the O(1)-space version, and a hash set answers the same questions.
  • K-way merge as a standalone: it's a heap application, and card 8 covers it.
  • Subsets-as-bit-manipulation: backtracking handles it more readably.

Union-Find sits just outside the fifteen; learn it after these if graph-heavy companies are on your list.

The 4-Week Execution Plan

Week one is pure ROI. Arrays and strings are the ultimate gatekeepers, guarding almost every first-round screen. Do not even look at week two until Cards 1 through 4 are permanently burned into your muscle memory. Week two adds structure: intervals, lists, stacks, heaps. By week three you are mixing both binary searches with both traversals to make things stick, and the last week is 13 through 15 plus redoing every problem you missed, because the redo is where recognition actually forms.

Solving three problems flawlessly destroys solving thirty poorly. Do the two on each card, pick one wild card yourself, and stop. After each solve, close the tab and say the cue out loud in one sentence. If you can't, the next problem in that pattern will feel brand new, and that feeling is the 500-solve trap from the intro.

The Part That Still Bites

The list itself decays. Cyclic sort was everywhere in 2019 and I cut it today. Whatever year you're reading this in, the loop has drifted again. Whichever pattern is quietly rising in 2027, cue-reading will spot it long before anyone updates a list.

None of this is a finish line. It's a perishable skill, and six months without practice is enough for the cues to evaporate completely. Keep drilling. When the marker hits the whiteboard and the clock starts, those first 60 seconds belong entirely to you.

Thank you for reading. If you found this useful, followPracHubfor more practical deep dives on engineering, system design, and interview preparation written to help you build skills that last beyond a single article.


Comments (0)


Related Articles

Designing a News Feed: Who Pays for the Delivery?

Learn how hybrid feed systems use fan-out, outboxes, ranking, and read-time merging to handle celebrity posts at scale.

1Software Engineer

One Consistency Level Broke Our Store. Now Every Route Gets Its Own Choice.

Learn how CAP theorem, PACELC, quorum reads, and per-route consistency choices affect multi-region product pages and checkout flows.

Software Engineer

Load Balancing vs Consistent Hashing: The 80% Cache Mistake

Load balancers spread traffic; consistent hashing owns state. A production war story on cache remap storms, hash rings, virtual nodes, and hot-key salting.

Software Engineer

Apple Software Engineer Interview: The Complete Guide (2026)

Master the 2026 Apple software engineer interview. Covers coding, privacy-first system design, the "Why Apple?" round, and what makes Apple different from FAANG

1Software Engineer
PracHub

Master your tech interviews with 8,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • AI Coding Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.