- Published on
LeetCode Interview Preparation Crash Course
- Authors

- Name
- Gene Zhang
LeetCode Interview Preparation Crash Course
A comprehensive collection of curated LeetCode problems organized by pattern and data structure to efficiently prepare for technical interviews. Each problem includes detailed explanations, multiple approaches, time/space complexity analysis, and key insights.
How to Use This Guide
- Start with fundamentals - Begin with Array, Two Pointers, and Binary Search
- Master patterns - Focus on understanding the pattern, not memorizing solutions
- Practice consistently - Do at least 1-2 problems daily
- Review regularly - Revisit problems to reinforce patterns
- Code without looking - Try to solve from memory to ensure understanding
Study Plan Recommendation
Week 1-2: Fundamentals
- Array & Sliding Window
- Two Pointers
- Binary Search
- Stack & Queue
Week 3-4: Trees & Graphs
- Binary Tree
- Graph Algorithms (BFS, DFS, Topological Sort)
Week 5-6: Advanced Patterns
- Dynamic Programming
- Backtracking
- Heap/Priority Queue
Week 7-8: Specialized Topics
- Trie
- Greedy Algorithms
- Sorting Algorithms
- String Manipulation
š Topics Overview
1. Array (7 problems)
Key Patterns: Kadane's Algorithm, Prefix/Suffix, Sliding Window, Monotonic Deque, Intervals
- Two Sum (LC 1) - Hash map for pair finding
- Maximum Subarray (LC 53) - Kadane's algorithm for max sum subarray
- Merge Intervals (LC 56) - Sorting + merging intervals
- Maximum Gap (LC 164) - Bucket sort optimization
- Contains Duplicate II (LC 219) - Sliding window with hash map
- Product of Array Except Self (LC 238) - Prefix/suffix products
- Sliding Window Maximum (LC 239) - Monotonic deque for window extremes
- Flatten 2D Vector (LC 251) - Iterator design pattern
- Pour Water (LC 755) - Simulation with two-pointer
When to use: Array traversal, subarray problems, window-based optimization, interval problems
2. Two Pointers (2 problems)
Key Patterns: Left-Right pointers, Fast-Slow pointers, Greedy movement
- Container With Most Water (LC 11) - Greedy two-pointer strategy
- 3Sum (LC 15) - Two pointers with sorting
- Trapping Rain Water (LC 42) - Two pointers tracking max heights
When to use: Sorted arrays, pair finding, optimization problems
3. Binary Search (6 problems)
Key Patterns: Standard binary search, Rotated array search, Finding boundaries, Median finding
- Median of Two Sorted Arrays (LC 4) - Binary search for kth element
- Search in Rotated Sorted Array (LC 33) - Modified binary search
- Search Rotated Array II (LC 81) - With duplicates
- Find Minimum in Rotated Sorted Array (LC 153) - Finding rotation point
- Find Peak Element (LC 162) - Binary search on unsorted
- Binary Search (LC 704) - Classic binary search template
When to use: Sorted/rotated arrays, finding boundaries, optimization (minimize/maximize)
4. Binary Tree (5 problems)
Key Patterns: DFS traversals, BFS level-order, Recursion, BST properties
- Binary Tree Inorder Traversal (LC 94) - Tree traversal fundamentals
- Validate BST (LC 98) - BST validation with range constraints
- Level Order Traversal (LC 102) - BFS with level tracking
- Maximum Depth (LC 104) - DFS depth calculation
- Convert Sorted Array to BST (LC 108) - Balanced BST construction
- Binary Tree Maximum Path Sum (LC 124) - Post-order DFS
- Lowest Common Ancestor (LC 236) - Bottom-up DFS
- Serialize and Deserialize Binary Tree (LC 297) - Tree encoding
When to use: Tree problems, hierarchical data, path finding
5. Graph (13 problems)
Key Patterns: DFS/BFS, Cycle detection, Topological sort, Connected components, Shortest path
- Word Ladder (LC 127) - BFS shortest path
- Word Ladder II (LC 126) - BFS + backtracking
- Longest Consecutive Sequence (LC 128) - Union-find or hash set
- Clone Graph (LC 133) - Graph cloning with HashMap
- Number of Islands (LC 200) - DFS/BFS for connected components
- Course Schedule (LC 207) - Cycle detection, topological sort
- Alien Dictionary (LC 269) - Topological sort
- Number of Connected Components (LC 323) - Union-find
- Longest Increasing Path in Matrix (LC 329) - DFS with memoization
- Pacific Atlantic Water Flow (LC 417) - Multi-source DFS
- Network Delay Time (LC 743) - Dijkstra's algorithm
- Sliding Puzzle (LC 773) - BFS on state space
- Cheapest Flights Within K Stops (LC 787) - Modified Dijkstra
When to use: Relationship problems, dependencies, reachability, shortest paths
6. Dynamic Programming (8 problems)
Key Patterns: Optimal substructure, Overlapping subproblems, State transitions
- Regular Expression Matching (LC 10) - 2D DP with wildcards
- Longest Palindromic Substring (LC 5) - Expand around center / DP
- Climbing Stairs (LC 70) - Basic DP / Fibonacci
- House Robber (LC 198) - DP with choice
- Maximal Square (LC 221) - 2D DP
- Longest Increasing Subsequence (LC 300) - Classic DP with O(n log n) optimization
- Burst Balloons (LC 312) - Interval DP
- Coin Change (LC 322) - Unbounded knapsack
When to use: Optimization problems, counting problems, decision-making with constraints
7. Backtracking (7 problems)
Key Patterns: Choose-Explore-Unchoose, State restoration, Constraint satisfaction
- Letter Combinations of Phone Number (LC 17) - Basic backtracking
- Generate Parentheses (LC 22) - Backtracking with constraints
- Combination Sum (LC 39) - Backtracking with reusable elements
- Permutations (LC 46) - Generating all permutations
- N-Queens (LC 51) - Constraint satisfaction
- Subsets (LC 78) - Power set generation
- Pyramid Transition Matrix (LC 756) - DFS with pruning
When to use: Generating combinations/permutations, constraint satisfaction, exhaustive search
8. Heap / Priority Queue (7 problems)
Key Patterns: Top K, K-way merge, Two heaps, Streaming median
- Merge K Sorted Lists (LC 23) - K-way merge with heap
- Kth Largest Element (LC 215) - Min-heap for Kth largest
- Find Median from Data Stream (LC 295) - Two heaps (max + min)
- Top K Frequent Elements (LC 347) - Heap + HashMap
- Data Stream as Disjoint Intervals (LC 352) - Heap + TreeMap
- LFU Cache (LC 460) - Heap-like with hash maps
- Sliding Window Median (LC 480) - Two heaps sliding
When to use: Top K problems, merging sorted data, streaming data, priority-based processing
9. Trie (2 problems)
Key Patterns: Prefix operations, Dictionary operations, Word search optimization
- Implement Trie (LC 208) - Basic trie implementation
- Word Search II (LC 212) - Trie + DFS backtracking
- Design File System (Custom) - Trie for path operations
When to use: Prefix matching, autocomplete, dictionary operations, word search optimization
10. Stack & Queue (3 problems)
Key Patterns: Matching pairs, Monotonic stack, Next greater/smaller element
- Valid Parentheses (LC 20) - Stack for matching
- Min Stack (LC 155) - Auxiliary stack for O(1) operations
- Daily Temperatures (LC 739) - Monotonic stack
When to use: Matching/balancing, maintaining order, next greater/smaller problems
11. Greedy (3 problems)
Key Patterns: Local optimal choices, Proof of correctness, Scheduling
- Jump Game (LC 55) - Greedy reachability
- Meeting Rooms II (LC 253) - Greedy scheduling with heap
- Employee Free Time (LC 759) - Interval merging
When to use: Optimization where local choices lead to global optimum, scheduling
12. Sorting (2 problems)
Key Patterns: Divide and conquer, Partitioning, Comparison-based sorting
- Merge Sort - Stable O(n log n) sort
- Quick Sort - In-place O(n log n) average sort
When to use: Understanding sorting fundamentals, custom comparators, external sorting
13. String (5 problems)
Key Patterns: Sliding window, Character frequency, Two pointers, Palindrome, Trie
- Longest Substring Without Repeating Characters (LC 3) - Sliding window
- Valid Anagram (LC 242) - Character frequency
- Palindrome Pairs (LC 336) - Trie + palindrome checking
- Palindromic Substrings (LC 647) - Expand around center
- IP to CIDR (LC 751) - Bit manipulation
When to use: Substring problems, character manipulation, pattern matching
14. Linked List (3 problems)
Key Patterns: Two pointers, Dummy node, In-place reversal, LRU design
- Reverse Linked List II (LC 92) - In-place reversal
- LRU Cache (LC 146) - Doubly linked list + hash map
- Sort Linked List (LC 148) - Merge sort for linked lists
- Intersection of Two Linked Lists (LC 160) - Two pointers
When to use: List manipulation, reversal, sorting without arrays
15. Divide and Conquer (1 problem)
Key Patterns: Break into subproblems, Combine solutions
- Sort Linked List (LC 148) - Merge sort pattern
When to use: Problems that can be broken into independent subproblems
šÆ Quick Reference: Pattern Recognition
When you see these keywords, think:
- "Contiguous subarray" ā Sliding Window, Kadane's Algorithm
- "Two sum, three sum" ā Two Pointers, Hash Map
- "Sorted array" ā Binary Search, Two Pointers
- "Tree traversal" ā DFS, BFS
- "Shortest path" ā BFS, Dijkstra
- "Connected components" ā DFS, BFS, Union-Find
- "Optimal/Maximum/Minimum with choices" ā Dynamic Programming, Greedy
- "All possible combinations" ā Backtracking
- "Top K elements" ā Heap
- "Prefix matching" ā Trie
- "Next greater/smaller" ā Monotonic Stack
- "Matching pairs" ā Stack
- "Window of unique elements" ā Sliding Window + Hash Set
š Complexity Cheat Sheet
Common Time Complexities (from best to worst):
- O(1) - Constant
- O(log n) - Logarithmic (Binary Search, Balanced Tree operations)
- O(n) - Linear (Array traversal, Hash Table lookup)
- O(n log n) - Linearithmic (Efficient sorting, Heap operations on n items)
- O(n²) - Quadratic (Nested loops)
- O(2āæ) - Exponential (Recursive branching without memoization)
- O(n!) - Factorial (Permutations)
Space Complexity Considerations:
- Recursion depth contributes to space complexity
- Hash maps trade space for time
- In-place algorithms are space-optimal but may be harder to implement
š Key Interview Tips
- Clarify the problem - Ask about edge cases, constraints, input format
- Think out loud - Communicate your thought process
- Start with brute force - Then optimize
- Consider time-space tradeoffs - Sometimes using more space gives better time
- Test with examples - Walk through your solution with test cases
- Discuss edge cases - Empty input, single element, duplicates, etc.
- Know your complexities - Always analyze time and space complexity
š Progress Tracking
Total Problems: 70+ (with detailed solutions and explanations)
Suggested completion order:
- ā Complete all Array, Two Pointers, Binary Search (Foundation)
- ā Master Binary Tree and Stack/Queue (Essential data structures)
- ā Practice Graph problems (Common in interviews)
- ā Tackle Dynamic Programming (Most challenging)
- ā Learn Backtracking patterns (Combination problems)
- ā Understand Heap operations (Top K problems)
- ā Review Trie, Greedy, Sorting (Specialized patterns)
š Next Steps After This Crash Course
- Do more variations - Each pattern has 10-20 more problems on LeetCode
- Practice mock interviews - Use platforms like Pramp, interviewing.io
- Review company-specific patterns - Check Blind 75, Grind 75
- Build projects - Apply algorithms to real problems
- Contribute to discussions - Teach others to reinforce learning
š Additional Resources
- LeetCode Patterns
- NeetCode Roadmap
- Blind 75
- Visualgo - Algorithm visualizations
Remember: The goal isn't to memorize solutions, but to recognize patterns and understand the underlying principles. Happy coding! š