LeetCode Cheatsheet
Fifty of the most commonly asked interview problems, grouped by the pattern that solves them.
How to use this guide
Section titled “How to use this guide”- Pick a pattern below (or in the sidebar) and read its Overview: when to reach for it, plus a template.
- Open a problem. Read the statement and try it yourself first.
- Only then reveal the solution, in Python, TypeScript or Java.
- Mark the problem Done if you could have written it cold, or Needs review if not.
- The day before the interview, redo the Needs review pile using the filter below.
Stuck matching a problem to an approach? See the pattern cheatsheet. Need complexities fast? See the Big-O reference.
Your progress
Section titled “Your progress”0 of 50 done0 to review
Arrays & Hashing0/5
- Two Sum (to do)Easy#1
- Group Anagrams (to do)Medium#49
- Top K Frequent Elements (to do)Medium#347
- Product of Array Except Self (to do)Medium#238
- Longest Consecutive Sequence (to do)Medium#128
Two Pointers0/4
- Valid Palindrome (to do)Easy#125
- Container With Most Water (to do)Medium#11
- 3Sum (to do)Medium#15
- Trapping Rain Water (to do)Hard#42
Sliding Window0/3
Stack0/3
- Valid Parentheses (to do)Easy#20
- Min Stack (to do)Medium#155
- Daily Temperatures (to do)Medium#739
Binary Search0/2
- Binary Search (to do)Easy#704
- Search in Rotated Sorted Array (to do)Medium#33
Linked List0/5
- Reverse Linked List (to do)Easy#206
- Merge Two Sorted Lists (to do)Easy#21
- Linked List Cycle (to do)Easy#141
- Remove Nth Node From End of List (to do)Medium#19
- LRU Cache (to do)Medium#146
Trees0/6
Heap0/3
Backtracking0/4
- Subsets (to do)Medium#78
- Combination Sum (to do)Medium#39
- Permutations (to do)Medium#46
- Word Search (to do)Medium#79
Graphs0/4
- Number of Islands (to do)Medium#200
- Clone Graph (to do)Medium#133
- Course Schedule (to do)Medium#207
- Rotting Oranges (to do)Medium#994
Tries0/1
- Implement Trie (Prefix Tree) (to do)Medium#208
1-D Dynamic Programming0/6
- Climbing Stairs (to do)Easy#70
- House Robber (to do)Medium#198
- Maximum Subarray (to do)Medium#53
- Coin Change (to do)Medium#322
- Word Break (to do)Medium#139
- Longest Increasing Subsequence (to do)Medium#300
2-D Dynamic Programming0/2
- Unique Paths (to do)Medium#62
- Longest Common Subsequence (to do)Medium#1143
Intervals0/2
- Merge Intervals (to do)Medium#56
- Meeting Rooms II (to do)Medium#253
Nothing here.