Is input sorted?
YES → Binary Search or Two Pointers
NO → continue
Is it a graph/tree problem?
YES, unweighted shortest path → BFS
YES, weighted shortest path → Dijkstra (no neg) / Bellman-Ford (neg)
YES, dependency/ordering → Topological Sort
YES, connectivity → DFS or Union Find
NO → continue
Does it involve substrings/prefixes?
YES, prefix lookup → Trie
YES, repeated substrings → Suffix Array
NO → continue
Does it ask for ALL solutions?
YES → Backtracking
NO → continue
Does it ask for count/min/max and has overlapping subproblems?
YES → Dynamic Programming
NO → continue
Contiguous subarray?
YES → Sliding Window
NO → continue
Top K elements?
YES → Heap
NO → continue
Local best choice = global best?
YES → Greedy
Common Mistake Patterns
Mistake
Correct Approach
Using O(n²) nested loops on a subarray
Sliding window
BFS on a weighted graph
Dijkstra
DFS without visited set (infinite loop)
Always track visited
DP without defining state first
Write recurrence in English first
Backtracking without pruning (TLE)
Add validity check before recursing
Greedy when DP is needed
Verify exchange argument — if greedy doesn’t provably work, use DP
Must-Do Rating Legend
Used in problem tables across all topic pages:
Rating
Meaning
✅
Must-do — extremely common in interviews, foundational pattern
⚡
High value — good ROI, appears in top-tier interviews
📖
Learning problem — builds intuition, less common in interviews