Why Learn by Patterns?
Most coding interviews test the same 22 core patterns repeatedly. Instead of solving 1000+ random problems, understanding these patterns helps you:- Recognize problem types instantly
- Apply proven templates to new problems
- Optimize solutions systematically
- Explain your thought process clearly
Pattern Categories
Array & String Patterns
Two Pointers, Sliding Window, Prefix Sum
Search & Sort
Binary Search, Sorting Algorithms
Graph Patterns
DFS, BFS, Union Find, Graph Algorithms
Dynamic Programming
Memoization, Tabulation, State Transitions
Data Structure Patterns
HashMap, Stack, Queue, Heap, Trie
Advanced Techniques
Backtracking, Greedy, Divide & Conquer
Pattern Selection Flowchart
Use this decision tree when you encounter a new problem:Quick Pattern Recognition Cheat Sheet
Keywords that Signal Each Pattern
Keywords that Signal Each Pattern
| If you see… | Think… |
|---|---|
| “sorted array”, “find pair with sum” | Two Pointers |
| ”contiguous subarray”, “window of size k” | Sliding Window |
| ”find in sorted”, “minimize/maximize” | Binary Search |
| ”frequency”, “anagram”, “contains” | HashMap |
| ”all paths”, “connected components” | DFS |
| ”shortest path”, “level order” | BFS |
| ”maximum/minimum with constraints” | Dynamic Programming |
| ”generate all”, “permutations”, “combinations” | Backtracking |
| ”optimal choice at each step” | Greedy |
| ”k largest/smallest”, “merge sorted” | Heap |
| ”matching brackets”, “undo” | Stack |
| ”prefix/autocomplete” | Trie |
| ”connected groups”, “union/merge” | Union Find |
Memory Tricks (Mnemonics)
Memory Tricks (Mnemonics)
STAMPS - For Two Pointer problems:
- Sorted array?
- Two elements needed?
- Avoid nested loops?
- Move based on comparison?
- Pairs/Triplets?
- Space O(1) possible?
- Subarray/Substring problem?
- Length constraints?
- Iterate once?
- Dynamic window possible?
- Expand and shrink?
- Decision at each step?
- Recurrence relation possible?
- Every subproblem needed?
- Answer from subproblems?
- Duplicate subproblems?
Learning Path
1
Foundation (Week 1-2)
Start with Two Pointers, Sliding Window, and HashMap patterns. These appear in 40% of interview questions.Daily Goals: 2-3 easy problems + 1 medium problem
2
Core Patterns (Week 3-4)
Master Binary Search, DFS/BFS, and Stack/Queue patterns. Build intuition for when to apply each.Daily Goals: 1-2 easy + 2 medium problems
3
Intermediate (Week 5-6)
Tackle Dynamic Programming, Backtracking, and Greedy approaches. Focus on state definition.Daily Goals: 2-3 medium problems + analyze solutions
4
Advanced (Week 7-8)
Learn Trie, Union Find, Monotonic Stack, and Bit Manipulation for specialized problems.Daily Goals: 1-2 medium + 1 hard problem
8-Week Study Calendar
- Week 1-2: Foundation
- Week 3-4: Core
- Week 5-6: Intermediate
- Week 7-8: Advanced
| Day | Topic | Problems to Solve |
|---|---|---|
| 1 | Two Pointers Intro | Two Sum II, Valid Palindrome |
| 2 | Two Pointers Practice | 3Sum, Container With Most Water |
| 3 | Sliding Window Fixed | Max Sum Subarray, Avg of Subarrays |
| 4 | Sliding Window Variable | Longest Substring Without Repeat |
| 5 | HashMap Basics | Two Sum, Contains Duplicate |
| 6 | HashMap + Frequency | Valid Anagram, Group Anagrams |
| 7 | Review + Mixed Practice | Solve 3 random problems |
Pattern Difficulty Matrix
| Pattern | Difficulty | Frequency | Time to Learn | Interview Importance |
|---|---|---|---|---|
| Two Pointers | Easy | Very High | 2-3 days | Very High |
| Sliding Window | Easy | Very High | 2-3 days | Very High |
| HashMap | Easy | Very High | 1-2 days | Very High |
| Binary Search | Medium | Very High | 3-4 days | Very High |
| DFS/BFS | Medium | High | 4-5 days | Very High |
| Stack/Queue | Easy | High | 2-3 days | High |
| Heap | Medium | Medium | 3-4 days | High |
| Dynamic Programming | Hard | Very High | 2-3 weeks | Very High |
| Backtracking | Medium | Medium | 4-5 days | High |
| Greedy | Medium | Medium | 3-4 days | Medium |
| Trie | Medium | Low | 2-3 days | Medium |
| Union Find | Medium | Medium | 3-4 days | High |
| Monotonic Stack | Hard | Low | 3-4 days | Medium |
| Bit Manipulation | Medium | Low | 2-3 days | Low |
Company-Wise Pattern Frequency
- Google
- Amazon
- Meta
- Microsoft
- Dynamic Programming (25%)
- Graph Algorithms (20%)
- Binary Search (15%)
- Two Pointers/Sliding Window (15%)
- HashMap/HashSet (10%)
- Others (15%)
Success Tips
Spaced Repetition
Review solved problems after 1 day, 3 days, 7 days, and 14 days to build long-term memory.
Teach Others
Explain your solutions out loud or write blog posts. Teaching reinforces understanding.
Time Yourself
Practice with 45-minute limits. Real interviews are time-constrained.
Debug Without IDE
Practice tracing code on paper. Build mental debugging skills.