1. Sliding Window
The sliding window pattern maintains a dynamic window over a contiguous subarray or substring, expanding and contracting to find an optimal solution. Use it when the problem asks for the longest/shortest subarray or substring satisfying a constraint.
Recognition signal: “Find the longest substring with at most K distinct characters” or “minimum size subarray sum.”
Canonical problem: LeetCode 3 — Longest Substring Without Repeating Characters
def sliding_window(s):
window = {} # char -> count
left = 0
result = 0
for right in range(len(s)):
window[s[right]] = window.get(s[right], 0) + 1
while window_invalid(window): # shrink condition
window[s[left]] -= 1
if window[s[left]] == 0:
del window[s[left]]
left += 1
result = max(result, right - left + 1)
return resultCommon mistake under pressure: Forgetting to clean up the window map when the count reaches zero, leading to incorrect “distinct characters” counts.
2. Two Pointers
Two pointers uses a pair of indices moving through a sorted array (or from both ends) to find pairs or partitions satisfying a condition. It reduces O(n²) brute force to O(n).
Recognition signal: “Find two numbers that sum to target” in a sorted array, or “remove duplicates in-place.”
Canonical problem: LeetCode 167 — Two Sum II (Input Array Is Sorted)
def two_sum_sorted(nums, target):
left, right = 0, len(nums) - 1
while left < right:
total = nums[left] + nums[right]
if total == target:
return [left, right]
elif total < target:
left += 1
else:
right -= 1
return []Common mistake under pressure: Using two pointers on an unsorted array without sorting first, or missing the edge case where left == right.
3. Binary Search
Binary search divides the search space in half at each step. Beyond sorted array lookups, it applies to any problem with a monotonic predicate — “find the minimum value where condition(x) is true.”
Recognition signal: “Find the minimum/maximum that satisfies...” or any problem on a sorted input.
Canonical problem: LeetCode 875 — Koko Eating Bananas
def binary_search(lo, hi, condition):
while lo < hi:
mid = (lo + hi) // 2
if condition(mid):
hi = mid # mid could be answer
else:
lo = mid + 1 # mid too small
return loCommon mistake under pressure: Off-by-one errors in the boundary conditions. Using lo <= hi vs lo < hi and hi = mid vs hi = mid - 1 incorrectly.
4. Depth-First Search (DFS)
DFS explores as deep as possible along each branch before backtracking. Essential for tree traversals, graph connectivity, path finding, and backtracking problems.
Recognition signal: “Find all paths,” “number of islands,” or any tree/graph traversal.
Canonical problem: LeetCode 200 — Number of Islands
def dfs(grid, r, c, visited):
if (r < 0 or r >= len(grid) or
c < 0 or c >= len(grid[0]) or
grid[r][c] == '0' or (r, c) in visited):
return
visited.add((r, c))
for dr, dc in [(0,1),(0,-1),(1,0),(-1,0)]:
dfs(grid, r + dr, c + dc, visited)Common mistake under pressure: Forgetting to mark cells as visited before recursing, causing infinite loops. Or modifying the grid in-place without realizing the interviewer expects immutability.
5. Breadth-First Search (BFS)
BFS explores all neighbors at the current depth before moving deeper. It's the go-to pattern for shortest path in unweighted graphs, level-order traversals, and minimum steps problems.
Recognition signal: “Shortest path,” “minimum number of steps,” or “level order traversal.”
Canonical problem: LeetCode 102 — Binary Tree Level Order Traversal
from collections import deque
def bfs(root):
if not root:
return []
result = []
queue = deque([root])
while queue:
level = []
for _ in range(len(queue)):
node = queue.popleft()
level.append(node.val)
if node.left: queue.append(node.left)
if node.right: queue.append(node.right)
result.append(level)
return resultCommon mistake under pressure: Using a list instead of deque for the queue, causing O(n) popleft operations. Or forgetting to capture the current queue length before the inner loop.
When pattern recall fails under pressure — this is exactly the scenario faFAANG's Coding Mode is built for. Press Ctrl+D to screenshot the problem statement. Press Ctrl+S to transcribe your verbal reasoning and submit to your own ChatGPT/Codex account. The response streams into a click-through overlay — visible to you, excluded from screen capture via WDA_EXCLUDEFROMCAPTURE. Your cursor never leaves the code editor.
6. Dynamic Programming
Dynamic programming breaks problems into overlapping subproblems and stores their solutions. The key insight is defining the state and the transition. If you can express the answer to the current state in terms of smaller states, it's DP.
Recognition signal: “Count the number of ways,” “minimum cost,” or “can you reach the target?”
Canonical problem: LeetCode 322 — Coin Change
def coin_change(coins, amount):
dp = [float('inf')] * (amount + 1)
dp[0] = 0
for i in range(1, amount + 1):
for coin in coins:
if coin <= i:
dp[i] = min(dp[i], dp[i - coin] + 1)
return dp[amount] if dp[amount] != float('inf') else -1Common mistake under pressure: Not initializing the base case correctly, or iterating in the wrong order for 0/1 knapsack variants (iterating coins in the outer loop vs inner loop changes the meaning).
7. Heap / Priority Queue
Heaps maintain a partially sorted structure that gives O(log n) insert and O(1) access to the minimum (or maximum) element. Use them for “top K,” “merge K sorted,” or any problem needing efficient access to extremes.
Recognition signal: “K largest elements,” “merge K sorted lists,” or “median of a stream.”
Canonical problem: LeetCode 215 — Kth Largest Element in an Array
import heapq
def kth_largest(nums, k):
heap = [] # min-heap of size k
for num in nums:
heapq.heappush(heap, num)
if len(heap) > k:
heapq.heappop(heap)
return heap[0]Common mistake under pressure: Python's heapq is a min-heap. For K largest, you need a min-heap of size K (smallest element on top = Kth largest). Confusing min/max heap direction is the #1 error.
8. Topological Sort
Topological sort produces a linear ordering of vertices in a DAG such that for every edge u→v, u appears before v. Essential for dependency resolution, course scheduling, and build order problems.
Recognition signal: “Order of courses with prerequisites” or “build order given dependencies.”
Canonical problem: LeetCode 207 — Course Schedule
from collections import deque, defaultdict
def topo_sort(num_courses, prerequisites):
graph = defaultdict(list)
in_degree = [0] * num_courses
for course, prereq in prerequisites:
graph[prereq].append(course)
in_degree[course] += 1
queue = deque(i for i in range(num_courses) if in_degree[i] == 0)
order = []
while queue:
node = queue.popleft()
order.append(node)
for neighbor in graph[node]:
in_degree[neighbor] -= 1
if in_degree[neighbor] == 0:
queue.append(neighbor)
return len(order) == num_courses # True if no cycleCommon mistake under pressure: Building the adjacency list in the wrong direction (prerequisite → course vs course → prerequisite), which inverts the entire ordering.
9. Union-Find (Disjoint Set Union)
Union-Find tracks a collection of disjoint sets with near-constant time union and find operations. It's the most efficient pattern for connected components, cycle detection in undirected graphs, and grouping problems.
Recognition signal: “Number of connected components,” “are these two nodes connected?” or “group accounts.”
Canonical problem: LeetCode 547 — Number of Provinces
class UnionFind:
def __init__(self, n):
self.parent = list(range(n))
self.rank = [0] * n
def find(self, x):
if self.parent[x] != x:
self.parent[x] = self.find(self.parent[x]) # path compression
return self.parent[x]
def union(self, x, y):
px, py = self.find(x), self.find(y)
if px == py: return False
if self.rank[px] < self.rank[py]: px, py = py, px
self.parent[py] = px
if self.rank[px] == self.rank[py]: self.rank[px] += 1
return TrueCommon mistake under pressure: Forgetting path compression in find(), which degrades performance from near-O(1) to O(n) in the worst case.
10. Trie (Prefix Tree)
A trie stores a dynamic set of strings with shared prefixes. It provides O(L) lookup, insert, and prefix search where L is the string length. Essential for autocomplete, word search, and prefix matching problems.
Recognition signal: “Implement autocomplete,” “word search in a grid,” or “find all words with this prefix.”
Canonical problem: LeetCode 208 — Implement Trie
class TrieNode:
def __init__(self):
self.children = {}
self.is_end = False
class Trie:
def __init__(self):
self.root = TrieNode()
def insert(self, word):
node = self.root
for char in word:
if char not in node.children:
node.children[char] = TrieNode()
node = node.children[char]
node.is_end = True
def search(self, word):
node = self._find(word)
return node is not None and node.is_end
def starts_with(self, prefix):
return self._find(prefix) is not None
def _find(self, prefix):
node = self.root
for char in prefix:
if char not in node.children:
return None
node = node.children[char]
return nodeCommon mistake under pressure: Confusing search (must end at a word) with starts_with (prefix only). Missing the is_end check is the classic error.
When Your Memory Fails Under Pressure
You've seen all 10 patterns before. You've solved problems in each category. The issue is never knowledge — it's recall under pressure. When the timer is running, the interviewer is watching, and the problem doesn't obviously map to a pattern you've practiced, your mind goes blank.
This is exactly what faFAANG's Coding Mode is built for:
- ■
Ctrl+Dcaptures the problem statement from screen as a screenshot - ■
Ctrl+Sstarts local Moonshine transcription of your verbal reasoning, then stops and submits transcript + screenshots to your own ChatGPT/Codex account - ■The Codex response streams into the pane — visible to you on the local display, excluded from screen capture via
WDA_EXCLUDEFROMCAPTURE - ■Coding Mode locks to your chosen programming language so all generated code stays consistent
- ■The pane is click-through by default — your cursor stays in CoderPad the entire time
- ■
Ctrl+Shift+Left/Rightnavigates previous responses;Ctrl+Shift+Ljumps back to live
You've seen these patterns before. The problem isn't knowledge — it's recall under pressure. faFAANG's Coding Mode is a silent, structured prompt that surfaces exactly when your memory fails.
Continue Reading
Best AI Interview Copilot for Coding Interviews in 2025 — DSA, System Design, and Live Coding
12 min read
How to Answer Every Amazon Leadership Principle — With a Copilot That Actually Knows Your Stories
20 min read
21 Global Hotkeys. Zero Mouse Clicks. Why faFAANG's Keyboard System Is in a Different Category.
14 min read