Most people learn data structures and algorithms by grinding random problems. It works better to learn patterns: once you recognize a sliding window or a monotonic stack, dozens of problems become the same problem. This free sheet is organized that way. Work top to bottom, and do not move on from a pattern until you can solve a new problem in it without hints.
| Pattern | Problems (LeetCode #) |
|---|---|
| Arrays and hashing | Two Sum (1), Contains Duplicate (217), Group Anagrams (49), Top K Frequent Elements (347), Product of Array Except Self (238) |
| Two pointers | Valid Palindrome (125), 3Sum (15), Container With Most Water (11) |
| Sliding window | Best Time to Buy and Sell Stock (121), Longest Substring Without Repeating Characters (3), Minimum Window Substring (76), Sliding Window Maximum (239) |
| Stack and monotonic stack | Valid Parentheses (20), Daily Temperatures (739), Largest Rectangle in Histogram (84) |
| Binary search | Binary Search (704), Search in Rotated Sorted Array (33), Koko Eating Bananas (875) |
| Linked lists | Reverse Linked List (206), Merge Two Sorted Lists (21), Linked List Cycle (141) |
| Trees | Maximum Depth of Binary Tree (104), Binary Tree Level Order Traversal (102), Validate Binary Search Tree (98), Lowest Common Ancestor of a BST (235) |
| Heaps and selection | Kth Largest Element in an Array (215), Merge k Sorted Lists (23), Find Median from Data Stream (295) |
| Backtracking | Subsets (78), Combination Sum (39), Permutations (46) |
| Graphs | Number of Islands (200), Clone Graph (133), Course Schedule (207), Redundant Connection (684) |
| Dynamic programming | Climbing Stairs (70), House Robber (198), Coin Change (322), Longest Increasing Subsequence (300) |
Sliding window
Monotonic stack
Binary search templates
QuickSelect (for Kth Largest Element)
Working through a sheet alone is hard to keep up. SDE Skills, a volunteer-run 501(c)(3) nonprofit, runs free daily LeetCode practice on weekdays and a weekly data structures and algorithms session on Sundays, all on Zoom. See the schedule.
Join a session on Zoom Find study partners on Discord
More guides: How to practice LeetCode · Free mock interviews · System design interview prep