🌳
Which Pattern Should I Use?
Interactive decision tree to find the right approach
→
⚖️
Pattern Comparisons
Side-by-side guides like DFS vs BFS and DP variants
→
📋
Cheat Sheets
Quick reference for all 28 patterns
→
📐
Complexity Analysis
Understand Big O notation, analyze time and space complexity, and learn shortcuts for reasoning about algorithm performance.
→
👉
Two Pointers
Use two pointers moving toward or away from each other to solve problems on sorted arrays or linked lists in linear time.
→
🪟
Sliding Window
Maintain a dynamic window over a sequence to efficiently compute running aggregates or find optimal subarrays.
→
🔍
Modified Binary Search
Adapt classic binary search to handle rotated arrays, fuzzy boundaries, and non-trivial search conditions.
→
📊
Dynamic Programming
Break problems into overlapping subproblems and cache results to avoid redundant computation.
→
🔀
Backtracking
Explore all candidate solutions incrementally, pruning branches that violate constraints.
→
🌳
Tree Traversal
Navigate tree structures using pre-order, in-order, post-order, or level-order strategies.
→
📚
Monotonic Stack
Use a stack that maintains a monotonic order to solve next-greater-element and histogram problems in linear time.
→
🔄
In-Place Reversal
Reverse portions of a linked list in place without extra memory by re-wiring node pointers.
→
🐢
Fast & Slow Pointers
Advance two pointers at different speeds to detect cycles, find midpoints, or identify patterns in sequences.
→
➕
Prefix Sum
Precompute cumulative sums to answer range-sum queries and subarray-sum problems in constant time.
→
🗺
Matrix Traversal
Traverse 2D grids using BFS, DFS, or directional iteration to solve island, path, and region problems.
→
🕸
DFS & BFS
Explore graphs depth-first or breadth-first to find paths, connected components, and shortest routes.
→
📅
Overlapping Intervals
Sort and merge or compare intervals to detect overlaps, insert new ranges, or find gaps.
→
🏆
Top K Elements
Use heaps or quickselect to efficiently find the k largest, smallest, or most frequent elements.
→
🔤
Trie
Store and search strings efficiently using a prefix tree that shares common prefixes between words.
→
🔗
Union-Find
Track connected components using disjoint sets with union-by-rank and path compression for near-constant time operations.
→
📋
Topological Sort
Order vertices in a directed acyclic graph so every edge points forward, solving dependency and scheduling problems.
→
🎯
Greedy
Make the locally optimal choice at each step to build a globally optimal solution without backtracking.
→
⚡
Bit Manipulation
Use bitwise operators (AND, OR, XOR, shifts) to solve problems involving binary representations in constant space.
→
📈
Monotonic Queue
Maintain a double-ended queue in sorted order to find sliding window minimums or maximums in O(n) time.
→
⚖
Two Heaps
Use a max-heap and a min-heap together to efficiently track the median or partition elements into two balanced groups.
→
🔄
Cyclic Sort
Place each number at its correct index in one pass to find missing, duplicate, or out-of-place elements in O(n) time.
→
🧩
Subsets & Combinations
Enumerate all subsets, combinations, or permutations using systematic backtracking with distinct templates for each variant.
→
⛓
Linked List Techniques
Master dummy heads, merge strategies, partitioning, and intersection detection for linked list manipulation problems.
→
🏗
Design Patterns
Implement custom data structures like LRU caches, min stacks, and iterators that combine multiple primitives.
→
📐
Segment Tree
Answer range queries and point updates in O(log n) using a binary tree that stores aggregate values over intervals.
→
🔎
String Matching
Find patterns within text efficiently using KMP, Rabin-Karp, or Z-algorithm to avoid brute-force O(nm) comparisons.
→