Browse by Pattern
Recurring algorithmic blueprints top tech companies test in coding interviews.
Loops, recursion, space & complexity trade-offs
Dicts, heaps, matrices, binary search & templates
1D Dynamic Programming
Linear recurrence relations, state machines, and optimal decision subproblems
2D Dynamic Programming & Knapsack
Grid optimization, 0/1 knapsack, and dual string alignments
Greedy Algorithms
Making locally optimal choices that guarantee global optimal outcomes
Tree Breadth-First Search (BFS)
Level-order traversal and horizontal tier exploration using queues
Tree Depth-First Search (DFS)
Recursive top-down and bottom-up traversals on hierarchical structures
Binary Search & Modified BS
Logarithmic O(log N) search on sorted spaces, monotonic predicates, and answers
Matrix & Grid Traversal
Coordinate navigation, spiral unwrapping, and 2D cellular automations
Bit Manipulation
O(1) low-level bitwise operations, masks, and XOR parity tricks
Two Pointers
Opposite or parallel pointers traversing sequences in linear time O(N)
Prefix Sum & Hash Map
O(1) range queries and subarray sum lookups using cumulative totals
Top K Elements & Priority Queues
Tracking extremes, medians, and K largest/smallest elements in dynamic streams
Graph Traversal (BFS & DFS)
Shortest paths, flood fills, and connected components in arbitrary networks
Sliding Window
Dynamic and fixed-size windows over contiguous subarrays or substrings
Backtracking & Exhaustive Search
Combinations, permutations, and constraint satisfaction through pruned search trees
Monotonic Stack & Queue
Nearest greater/smaller elements and range extremums in linear time
Union-Find (Disjoint Set)
Connectivity, cycle detection, and clustering in undirected networks
Linked List In-Place Manipulation
Reversing, reordering, and partitioning pointer chains with O(1) space
Trie (Prefix Tree)
Efficient prefix matching, autocomplete, and dictionary lookups
Intervals & Overlap Scheduling
Managing overlapping timelines, meeting rooms, and range merges
Topological Sort (Kahn's & DFS)
Linear dependency ordering and cycle detection in Directed Acyclic Graphs (DAG)
Binary Search Tree (BST)
Ordered hierarchical storage with monotonic inorder traversal
Fast & Slow Pointers
Cycle detection and midpoint traversal using Floyd's Tortoise and Hare algorithm
Why Learn LeetCode Coding Patterns?
Rather than memorizing hundreds of disconnected questions, learning patterns enables you to solve any unseen interview problem.
Recognize Signals
Identify key problem clues: sorted array points to Two Pointers or Binary Search; contiguous subarray points to Sliding Window; shortest path points to BFS.
Reusable Templates
Apply standard algorithmic blueprints that handle complex loop conditions, off-by-one errors, and pointer boundaries reliably.
FAANG Relevance
Over 85% of interview questions asked at Google, Meta, Amazon, Apple, and Microsoft map directly to these 22 foundational patterns.