Blind 75 LeetCode Solutions: Python Code and the Key Insight for Every Problem
The complete Blind 75 LeetCode list with clean, tested Python solutions, time and space complexity, and a one-line key insight for each of the 75 problems. Use it to work through the Blind 75 in order, check your answer after you have tried a problem, and review the patterns (sliding window, two pointers, binary search, BFS/DFS, topological sort, dynamic programming, heaps, tries) that coding interviews keep coming back to.
Last reviewed: December 2026
Table of Contents
- What is the Blind 75?
- How to use this repo
- Study schedules (3, 5 and 8 weeks)
- The one-problem study loop
- The 75 problems with solutions
- The “Combination Sum” mix-up
- The six Premium problems and free alternatives
- Pattern cheat sheet: which technique when
- Templates worth knowing by heart
- Python toolkit for the Blind 75
- Blind 75 vs NeetCode 150 vs Grind 75 vs LeetCode 75
- Common mistakes
- Running the solutions and tests
- FAQ
- Where to go next
- Contributing
What is the Blind 75?
The Blind 75 is a list of 75 LeetCode problems picked by Yangshun Tay, then an engineer at Facebook (now Meta) and later the creator of the Tech Interview Handbook. He shared it on the anonymous professional forum Blind in a post titled “New Year Gift - Curated List of Top 75 LeetCode Questions to Save Your Time”. The name “Blind 75” comes from where it was posted.
The idea was simple: instead of grinding hundreds of random problems, do a small set that covers every common pattern once. The list has 10 categories:
| Category | Problems | What it trains |
|---|---|---|
| Array | 10 | Hash maps, prefix/suffix products, Kadane, binary search on rotated arrays, two pointers |
| Binary | 5 | Bit tricks: XOR, masks, n & (n - 1) |
| Dynamic Programming | 11 | 1-D and 2-D DP, knapsack-style counting, greedy vs DP |
| Graph | 8 | DFS/BFS on grids and adjacency lists, topological sort, union-find |
| Interval | 5 | Sort-then-sweep, greedy by end time, heaps of end times |
| Linked List | 6 | Pointer rewiring, fast/slow pointers, dummy heads |
| Matrix | 4 | In-place tricks, boundary walking, grid backtracking |
| String | 10 | Sliding window, counting, palindromes, stacks |
| Tree | 14 | Recursion on trees, BFS by level, BST properties, tries |
| Heap | 3 | Top-k, k-way merge, two-heap median |
That is 76 entries, because Merge K Sorted Lists appears under both Linked List and Heap. Counted once, it is 75 problems. By LeetCode’s own labels the 75 are 19 Easy, 49 Medium and 7 Hard, and 6 are LeetCode Premium (see free alternatives).
Yangshun later built Grind 75 as an updated, customisable version. The original Blind 75 is still the most widely shared version, which is why this repo keeps it exactly as posted, with one clarification about Combination Sum.
How to use this repo
- Pick a schedule below, or go top to bottom by category.
- Open the LeetCode link and try the problem for 25-40 minutes before you look at anything here.
- Stuck? Read only the key insight in the table. Close this page and try again.
- Then compare with the solution in
solutions/. Each function has a docstring that repeats the insight, and the code is kept short so the idea is visible. - Say the time and space complexity out loud. Check it against the table.
- Mark anything you needed help with and redo it from a blank editor in 3 days and again in 2 weeks. Spaced repetition beats volume.
Every solution is plain Python 3 using only the standard library. Function names are snake_case versions of the LeetCode method names; class-based problems (Trie, WordDictionary, MedianFinder, Codec) keep LeetCode’s exact method names so you can paste them into the LeetCode editor.
Study schedules (3, 5 and 8 weeks)
Pick the pace that fits your life. The weekly groups go from easier, foundational patterns to harder ones, and keep related problems together so each week builds on the last.
| Plan | Pace | Best for |
|---|---|---|
| 3 weeks | ~25 problems a week (3-4 a day) | You already know the patterns and want a full refresher before interviews |
| 5 weeks | ~15 a week (2-3 a day) | Most working engineers with interviews in 1-2 months |
| 8 weeks | ~10 a week (1-2 a day) plus a review day | Your first serious round of interview prep |
8-week plan
| Week | Focus | Problems |
|---|---|---|
| 1 | Hashing and simple arrays | Two Sum, Contains Duplicate, Valid Anagram, Group Anagrams, Best Time to Buy and Sell Stock, Valid Palindrome, Valid Parentheses, Top K Frequent Elements, Product of Array Except Self, Longest Consecutive Sequence, Encode and Decode Strings |
| 2 | Two pointers, sliding window, binary search | 3Sum, Container With Most Water, Longest Substring Without Repeating Characters, Longest Repeating Character Replacement, Minimum Window Substring, Find Minimum in Rotated Sorted Array, Search in Rotated Sorted Array, Maximum Subarray, Maximum Product Subarray |
| 3 | Linked lists and bits | Reverse Linked List, Merge Two Sorted Lists, Linked List Cycle, Remove Nth Node From End of List, Reorder List, Merge k Sorted Lists, Number of 1 Bits, Counting Bits, Missing Number, Reverse Bits, Sum of Two Integers |
| 4 | Trees part 1 | Invert Binary Tree, Maximum Depth of Binary Tree, Same Tree, Subtree of Another Tree, Lowest Common Ancestor of a BST, Binary Tree Level Order Traversal, Validate Binary Search Tree, Kth Smallest Element in a BST |
| 5 | Trees part 2, tries, heaps | Construct Binary Tree from Preorder and Inorder Traversal, Binary Tree Maximum Path Sum, Serialize and Deserialize Binary Tree, Implement Trie, Design Add and Search Words, Word Search II, Find Median from Data Stream |
| 6 | Graphs, matrices, intervals | Number of Islands, Clone Graph, Pacific Atlantic Water Flow, Course Schedule, Graph Valid Tree, Number of Connected Components, Alien Dictionary, Set Matrix Zeroes, Spiral Matrix, Rotate Image, Word Search |
| 7 | Intervals and 1-D DP | Insert Interval, Merge Intervals, Non-overlapping Intervals, Meeting Rooms, Meeting Rooms II, Climbing Stairs, House Robber, House Robber II, Jump Game |
| 8 | DP and palindromes | Coin Change, Decode Ways, Combination Sum IV, Word Break, Longest Increasing Subsequence, Unique Paths, Longest Common Subsequence, Longest Palindromic Substring, Palindromic Substrings |
That covers all 75. For the 5-week plan, merge weeks 1+2 (but leave Max Subarray and Max Product for week 2), 3+4, and do 5, 6 and 7+8 as written but faster. For 3 weeks, do weeks 1-3, 4-6 and 7-8 of the table.
Want a schedule generator instead? Grind 75 lets you set hours per week and builds a week-by-week plan, and the Tech Interview Handbook has a 5-week study plan built around the same idea.
The one-problem study loop
A loop that turns 75 problems into durable skill:
- Read and restate (2 min). Write the input, output and constraints in your own words. Constraints hint at the complexity: n up to 10^5 usually means O(n log n) or better.
- Examples (3 min). Work one example by hand, plus one edge case (empty input, one element, all equal, negatives).
- Brute force first (3 min). Say it and its complexity, even if you will not code it.
- Find the bottleneck. What repeated work can a hash map, a sort, a pointer or a stored subresult remove?
- Code (15-20 min). Clear names, no clever one-liners until it works.
- Test by hand. Trace your example. Then run it.
- Review. Compare with the solution here and write down the one sentence you would need to remember next time. That sentence is what the “Key insight” column is.
The 75 problems with solutions
Difficulty labels are LeetCode’s own. “LC” is the LeetCode problem number. Complexity uses n for input length, m x n for grids, h for tree height, L for word length and V/E for vertices/edges.
Array
Solutions: solutions/array.py
| # | Problem | LC | Difficulty | Key insight | Time | Space | Function |
|---|---|---|---|---|---|---|---|
| 1 | Two Sum | 1 | Easy | Store value -> index; check for the complement before inserting. | O(n) | O(n) | two_sum |
| 2 | Best Time to Buy and Sell Stock | 121 | Easy | Profit today = price minus the lowest price seen so far. | O(n) | O(1) | max_profit |
| 3 | Contains Duplicate | 217 | Easy | A set shrinks when there is a repeat. | O(n) | O(n) | contains_duplicate |
| 4 | Product of Array Except Self | 238 | Medium | Prefix product from the left times suffix product from the right; no division. | O(n) | O(1) extra | product_except_self |
| 5 | Maximum Subarray | 53 | Medium | Kadane: extend the running sum or restart at the current number. | O(n) | O(1) | max_subarray |
| 6 | Maximum Product Subarray | 152 | Medium | Track both max and min product ending here; a negative number swaps them. | O(n) | O(1) | max_product |
| 7 | Find Minimum in Rotated Sorted Array | 153 | Medium | Compare mid with the right end to know which side holds the drop. | O(log n) | O(1) | find_min_rotated |
| 8 | Search in Rotated Sorted Array | 33 | Medium | One half around mid is always sorted; test whether the target lives there. | O(log n) | O(1) | search_rotated |
| 9 | 3Sum | 15 | Medium | Sort, fix one value, two-pointer the rest, skip equal neighbours. | O(n^2) | O(1) extra | three_sum |
| 10 | Container With Most Water | 11 | Medium | Start wide and move the shorter wall; the taller wall can never do better. | O(n) | O(1) | max_area |
Binary
Solutions: solutions/binary.py
| # | Problem | LC | Difficulty | Key insight | Time | Space | Function |
|---|---|---|---|---|---|---|---|
| 11 | Sum of Two Integers | 371 | Medium | XOR is sum without carry, (a & b) « 1 is the carry; repeat with a 32-bit mask. | O(1) | O(1) | get_sum |
| 12 | Number of 1 Bits | 191 | Easy | n & (n - 1) clears the lowest set bit. | O(set bits) | O(1) | hamming_weight |
| 13 | Counting Bits | 338 | Easy | bits(i) = bits(i » 1) + (i & 1). | O(n) | O(n) | count_bits |
| 14 | Missing Number | 268 | Easy | XOR all indices and values; matched pairs cancel. | O(n) | O(1) | missing_number |
| 15 | Reverse Bits | 190 | Easy | Pop the low bit of n, push it onto the result, 32 times. | O(1) | O(1) | reverse_bits |
Dynamic Programming
Solutions: solutions/dynamic_programming.py
| # | Problem | LC | Difficulty | Key insight | Time | Space | Function |
|---|---|---|---|---|---|---|---|
| 16 | Climbing Stairs | 70 | Easy | ways(n) = ways(n-1) + ways(n-2): Fibonacci. | O(n) | O(1) | climb_stairs |
| 17 | Coin Change | 322 | Medium | dp[x] = 1 + min(dp[x - coin]); unbounded knapsack. | O(amount * coins) | O(amount) | coin_change |
| 18 | Longest Increasing Subsequence | 300 | Medium | Keep the smallest tail for each length and binary-search where each number goes. | O(n log n) | O(n) | length_of_lis |
| 19 | Longest Common Subsequence | 1143 | Medium | Match -> diagonal + 1, else max(up, left). | O(m*n) | O(n) | longest_common_subsequence |
| 20 | Word Break | 139 | Medium | ok[i] is true if some word ends at i and ok[start of that word] is true. | O(n * distinct word lengths) | O(n) | word_break |
| 21 | Combination Sum IV | 377 | Medium | Order matters, so loop over the target outside and the numbers inside. | O(target * n) | O(target) | combination_sum4 |
| 22 | House Robber | 198 | Medium | Best at house i = max(skip it, rob it + best two houses back). | O(n) | O(1) | rob |
| 23 | House Robber II | 213 | Medium | Circle: run House Robber without the first house and without the last. | O(n) | O(1) | rob_circular |
| 24 | Decode Ways | 91 | Medium | Stairs with rules: one digit if not ‘0’, two digits if 10-26. | O(n) | O(1) | num_decodings |
| 25 | Unique Paths | 62 | Medium | Paths to a cell = paths from above + paths from the left. | O(m*n) | O(n) | unique_paths |
| 26 | Jump Game | 55 | Medium | Greedy: keep the farthest reachable index; fail if you pass it. | O(n) | O(1) | can_jump |
Graph
Solutions: solutions/graph.py
| # | Problem | LC | Difficulty | Key insight | Time | Space | Function |
|---|---|---|---|---|---|---|---|
| 27 | Clone Graph | 133 | Medium | DFS with an old -> new map; the map is also the visited set. | O(V+E) | O(V) | clone_graph |
| 28 | Course Schedule | 207 | Medium | Topological sort (Kahn); a cycle leaves courses that never reach in-degree 0. | O(V+E) | O(V+E) | can_finish |
| 29 | Pacific Atlantic Water Flow | 417 | Medium | Reverse the flow: climb uphill from each ocean’s edge and intersect. | O(m*n) | O(m*n) | pacific_atlantic |
| 30 | Number of Islands | 200 | Medium | Each unvisited land cell starts an island; flood it so it is counted once. | O(m*n) | O(m*n) | num_islands |
| 31 | Longest Consecutive Sequence | 128 | Medium | Only count from numbers whose predecessor is missing. | O(n) | O(n) | longest_consecutive |
| 32 | Alien Dictionary (Premium; free on LintCode 892) | 269 | Hard | First differing letter of neighbouring words is an edge; topo-sort the letters. | O(total chars) | O(1) (alphabet) | alien_order |
| 33 | Graph Valid Tree (Premium; free on LintCode 178) | 261 | Medium | Exactly n-1 edges and no cycle (union-find). | O(E * alpha(n)) | O(n) | valid_tree |
| 34 | Number of Connected Components in an Undirected Graph (Premium; free on LintCode 3651) | 323 | Medium | Start at n components; every successful union removes one. | O(E * alpha(n)) | O(n) | count_components |
Interval
Solutions: solutions/interval.py
| # | Problem | LC | Difficulty | Key insight | Time | Space | Function |
|---|---|---|---|---|---|---|---|
| 35 | Insert Interval | 57 | Medium | Copy intervals before, merge the overlapping ones, copy the rest. | O(n) | O(n) | insert |
| 36 | Merge Intervals | 56 | Medium | Sort by start; stretch the last merged interval while the next overlaps. | O(n log n) | O(n) | merge |
| 37 | Non-overlapping Intervals | 435 | Medium | Greedy by earliest end; count the intervals you must drop. | O(n log n) | O(1) extra | erase_overlap_intervals |
| 38 | Meeting Rooms (Premium; free on LintCode 920) | 252 | Easy | Sort by start; any start before the previous end is a clash. | O(n log n) | O(1) extra | can_attend_meetings |
| 39 | Meeting Rooms II (Premium; free on LintCode 919) | 253 | Medium | Min-heap of end times; its size is the number of rooms in use. | O(n log n) | O(n) | min_meeting_rooms |
Linked List
Solutions: solutions/linked_list.py
| # | Problem | LC | Difficulty | Key insight | Time | Space | Function |
|---|---|---|---|---|---|---|---|
| 40 | Reverse Linked List | 206 | Easy | Re-point each node to the previous one in a single pass. | O(n) | O(1) | reverse_list |
| 41 | Linked List Cycle | 141 | Easy | Floyd: fast and slow pointers meet only inside a loop. | O(n) | O(1) | has_cycle |
| 42 | Merge Two Sorted Lists | 21 | Easy | Dummy head, always attach the smaller front node. | O(m+n) | O(1) | merge_two_lists |
| 43 | Merge k Sorted Lists | 23 | Hard | Min-heap of list fronts (also listed under Heap). | O(N log k) | O(k) | merge_k_lists |
| 44 | Remove Nth Node From End of List | 19 | Medium | Lead pointer n steps ahead; when it ends, the trailer is before the target. | O(n) | O(1) | remove_nth_from_end |
| 45 | Reorder List | 143 | Medium | Find the middle, reverse the second half, weave the two halves. | O(n) | O(1) | reorder_list |
Matrix
Solutions: solutions/matrix.py
| # | Problem | LC | Difficulty | Key insight | Time | Space | Function |
|---|---|---|---|---|---|---|---|
| 46 | Set Matrix Zeroes | 73 | Medium | Use row 0 and column 0 as marker arrays, plus one flag. | O(m*n) | O(1) | set_zeroes |
| 47 | Spiral Matrix | 54 | Medium | Walk an edge, then shrink that boundary; check bounds before the last two edges. | O(m*n) | O(1) extra | spiral_order |
| 48 | Rotate Image | 48 | Medium | Clockwise rotation = transpose, then reverse each row. | O(n^2) | O(1) | rotate |
| 49 | Word Search | 79 | Medium | Backtracking DFS; mark a cell used and restore it after. | O(mn3^L) | O(L) | exist |
String
Solutions: solutions/string.py
| # | Problem | LC | Difficulty | Key insight | Time | Space | Function |
|---|---|---|---|---|---|---|---|
| 50 | Longest Substring Without Repeating Characters | 3 | Medium | Sliding window; on a repeat, jump left past that char’s last index. | O(n) | O(alphabet) | length_of_longest_substring |
| 51 | Longest Repeating Character Replacement | 424 | Medium | Window is valid while length - top count <= k; the window never needs to shrink. | O(n) | O(26) | character_replacement |
| 52 | Minimum Window Substring | 76 | Hard | Expand until all needed chars are covered, then shrink from the left. | O(m+n) | O(alphabet) | min_window |
| 53 | Valid Anagram | 242 | Easy | Same characters, same counts. | O(n) | O(alphabet) | is_anagram |
| 54 | Group Anagrams | 49 | Medium | Group by a canonical key (sorted word or count tuple). | O(n k log k) | O(n k) | group_anagrams |
| 55 | Valid Parentheses | 20 | Easy | Stack of openers; each closer must match the top. | O(n) | O(n) | is_valid_parentheses |
| 56 | Valid Palindrome | 125 | Easy | Two pointers that skip non-alphanumeric characters. | O(n) | O(1) | is_palindrome |
| 57 | Longest Palindromic Substring | 5 | Medium | Expand around all 2n-1 centres. | O(n^2) | O(1) | longest_palindrome |
| 58 | Palindromic Substrings | 647 | Medium | Same centre expansion; every successful step is one palindrome. | O(n^2) | O(1) | count_substrings |
| 59 | Encode and Decode Strings (Premium; free on LintCode 659) | 271 | Medium | Length-prefix each string (“5#hello”) so any character is safe. | O(total length) | O(total length) | encode / decode |
Tree
Solutions: solutions/tree.py
| # | Problem | LC | Difficulty | Key insight | Time | Space | Function |
|---|---|---|---|---|---|---|---|
| 60 | Maximum Depth of Binary Tree | 104 | Easy | 1 + the deeper subtree. | O(n) | O(h) | max_depth |
| 61 | Same Tree | 100 | Easy | Both empty, or equal values and both subtrees match. | O(n) | O(h) | is_same_tree |
| 62 | Invert Binary Tree | 226 | Easy | Swap children at every node. | O(n) | O(h) | invert_tree |
| 63 | Binary Tree Maximum Path Sum | 124 | Hard | Return the best one-sided gain upward; update the answer with a path that bends here. | O(n) | O(h) | max_path_sum |
| 64 | Binary Tree Level Order Traversal | 102 | Medium | BFS, one level per loop using the queue’s current length. | O(n) | O(n) | level_order |
| 65 | Serialize and Deserialize Binary Tree | 297 | Hard | Preorder with null markers rebuilds the exact shape. | O(n) | O(n) | Codec |
| 66 | Subtree of Another Tree | 572 | Easy | Run Same Tree at every node of the big tree. | O(m*n) | O(h) | is_subtree |
| 67 | Construct Binary Tree from Preorder and Inorder Traversal | 105 | Medium | Next preorder value is the root; its inorder index splits left from right. | O(n) | O(n) | build_tree_pre_in |
| 68 | Validate Binary Search Tree | 98 | Medium | Pass down an open (low, high) range, not just the parent value. | O(n) | O(h) | is_valid_bst |
| 69 | Kth Smallest Element in a BST | 230 | Medium | Inorder traversal of a BST is sorted; stop at the k-th node. | O(h + k) | O(h) | kth_smallest |
| 70 | Lowest Common Ancestor of a Binary Search Tree | 235 | Medium | Walk down until p and q split to different sides. | O(h) | O(1) | lowest_common_ancestor |
| 71 | Implement Trie (Prefix Tree) | 208 | Medium | Nested maps of characters with an end-of-word marker. | O(L) per op | O(total chars) | Trie |
| 72 | Design Add and Search Words Data Structure | 211 | Medium | Trie; on ‘.’, try every child. | O(L) add, up to O(26^dots * L) search | O(total chars) | WordDictionary |
| 73 | Word Search II | 212 | Hard | One trie for all words, one DFS over the board; prune found branches. | O(mn4*3^(L-1)) worst case | O(total chars) | find_words |
Heap
Solutions: solutions/heap.py (Merge K Sorted Lists is in solutions/linked_list.py)
| # | Problem | LC | Difficulty | Key insight | Time | Space | Function |
|---|---|---|---|---|---|---|---|
| 74 | Top K Frequent Elements | 347 | Medium | Bucket sort by frequency (count -> values), read from the top. | O(n) | O(n) | top_k_frequent |
| 75 | Find Median from Data Stream | 295 | Hard | Max-heap for the low half, min-heap for the high half, sizes within one. | O(log n) add, O(1) median | O(n) | MedianFinder |
Merge K Sorted Lists is the third Heap problem in the original list. It is counted once, under Linked List, which is how the list reaches 75 and not 76.
The “Combination Sum” mix-up
The original Blind post lists a problem named “Combination Sum” under Dynamic Programming, but the link it uses points to Combination Sum IV (LC 377), a DP counting problem. Many later copies of the list “fix” the name and link to Combination Sum (LC 39) instead, which is a backtracking problem.
This repo follows the original link (LC 377) in the table, and also includes LC 39 as a bonus (combination_sum in solutions/dynamic_programming.py) because it is just as common in interviews. Do both: they teach different things.
| Combination Sum (39) | Combination Sum IV (377) | |
|---|---|---|
| Asks for | Every distinct set of numbers that sums to target | The number of ordered sequences that sum to target |
| Order matters? | No: [2,2,3] and [3,2,2] are the same | Yes: (1,1,2) and (2,1,1) count separately |
| Technique | Backtracking with a start index | 1-D DP, target in the outer loop |
| Gotcha | Without the start index you produce duplicates | If you swap the loops you count combinations, not sequences |
The six Premium problems and free alternatives
Six Blind 75 problems need LeetCode Premium. You do not need to pay to practise them: LintCode hosts free versions with the same idea (sign-up required), and NeetCode’s practice page also includes them.
| Problem | LeetCode | Free on LintCode | Pattern |
|---|---|---|---|
| Encode and Decode Strings | 271 | 659 | Length-prefix encoding |
| Alien Dictionary | 269 | 892 | Topological sort |
| Graph Valid Tree | 261 | 178 | Union-find or DFS |
| Number of Connected Components in an Undirected Graph | 323 | 3651 | Union-find |
| Meeting Rooms | 252 | 920 | Sort and compare neighbours |
| Meeting Rooms II | 253 | 919 | Min-heap of end times |
Small differences exist (LintCode’s Meeting Rooms uses an Interval class, and its Alien Dictionary expects the lexicographically smallest valid order), so read each statement before submitting. The solutions here are tested against the LeetCode-style inputs.
Pattern cheat sheet: which technique when
When you read a new problem, scan for these signals:
| If the problem says or implies… | Try | Blind 75 examples |
|---|---|---|
| “Find a pair / complement / have I seen this before?” | Hash map or set | Two Sum, Contains Duplicate, Longest Consecutive Sequence |
| Sorted array, or you can sort; pairs/triples | Two pointers | 3Sum, Container With Most Water, Valid Palindrome |
| “Longest / shortest substring or subarray with a condition” | Sliding window | Longest Substring Without Repeating, Character Replacement, Minimum Window |
| Sorted (even rotated) and O(log n) expected | Binary search | Find Minimum / Search in Rotated Sorted Array |
| “Answer for every index excluding itself” | Prefix and suffix passes | Product of Array Except Self |
| Matching brackets, “most recent unmatched” | Stack | Valid Parentheses |
| Linked list cycle, middle, n-th from end | Fast and slow pointers | Linked List Cycle, Reorder List, Remove Nth Node |
| Tree question | Recursion: what does each node return to its parent? | Max Depth, Max Path Sum, Validate BST |
| “Level by level”, “minimum steps” | BFS with a queue | Level Order Traversal |
| Grid of cells, connected regions | DFS/BFS flood fill | Number of Islands, Pacific Atlantic |
| Dependencies, “order of”, prerequisites | Topological sort | Course Schedule, Alien Dictionary |
| “Are these connected?”, counting groups, cycles in undirected graphs | Union-find | Graph Valid Tree, Connected Components |
| Overlapping ranges, scheduling | Sort by start (merge) or end (greedy) | Merge / Insert / Non-overlapping Intervals, Meeting Rooms |
| “Top k”, “k-th largest”, streaming median | Heap | Top K Frequent, Find Median, Merge k Sorted Lists |
| Prefix matching on many words | Trie | Implement Trie, Add and Search Words, Word Search II |
| “Count the ways”, “min/max cost”, choices that overlap | Dynamic programming | Climbing Stairs, Coin Change, House Robber, Decode Ways |
| “All combinations / all paths” with pruning | Backtracking | Word Search, Combination Sum (39) |
| Bit-level tricks or O(1) space with integers | XOR, masks | Missing Number, Number of 1 Bits, Sum of Two Integers |
A good habit: before coding, say “this looks like X because Y.” Interviewers reward that reasoning even if your first guess is wrong.
Templates worth knowing by heart
These skeletons appear again and again. Memorise the shape, not specific answers.
Binary search (find the first index where a condition becomes true):
lo, hi = 0, len(nums) - 1
while lo < hi:
mid = (lo + hi) // 2
if condition(mid):
hi = mid # mid might be the answer
else:
lo = mid + 1 # answer is strictly to the right
return lo
Sliding window (variable size):
left = 0
for right, x in enumerate(items):
add(x)
while window_is_invalid():
remove(items[left])
left += 1
best = max(best, right - left + 1)
BFS by level:
from collections import deque
queue = deque([start])
while queue:
for _ in range(len(queue)): # one level
node = queue.popleft()
for nxt in neighbours(node):
if nxt not in seen:
seen.add(nxt)
queue.append(nxt)
Topological sort (Kahn’s algorithm):
queue = deque(n for n in nodes if indegree[n] == 0)
order = []
while queue:
n = queue.popleft()
order.append(n)
for m in graph[n]:
indegree[m] -= 1
if indegree[m] == 0:
queue.append(m)
has_cycle = len(order) != len(nodes)
Union-find with path compression:
parent = list(range(n))
def find(x):
while parent[x] != x:
parent[x] = parent[parent[x]]
x = parent[x]
return x
def union(a, b):
ra, rb = find(a), find(b)
if ra == rb:
return False # already connected: this edge makes a cycle
parent[ra] = rb
return True
Backtracking:
def go(start, path):
if done(path):
results.append(path[:])
return
for i in range(start, len(choices)):
path.append(choices[i])
go(i + 1, path) # use i instead of i + 1 if a choice can repeat
path.pop()
1-D DP (bottom-up):
dp = [base] + [default] * n
for i in range(1, n + 1):
dp[i] = combine(dp[i - 1], dp[i - 2], ...)
Python toolkit for the Blind 75
| Tool | Use it for | Notes |
|---|---|---|
dict, set |
O(1) average lookups | The default answer to “have I seen this?” |
collections.Counter |
Character or value counts | Counter(a) == Counter(b) for anagrams |
collections.defaultdict(list) |
Grouping, adjacency lists | Graph building without key checks |
collections.deque |
BFS queues | popleft() is O(1); list.pop(0) is O(n) |
heapq |
Min-heaps | Push negatives for a max-heap; add an index to break ties between objects |
bisect.bisect_left |
Binary search on a sorted list | Powers the O(n log n) LIS |
functools.cache |
Top-down DP memoisation | Fast to write; watch recursion depth (default limit 1000) |
Slicing and [::-1] |
Reversals and copies | Each slice copies, so it costs O(k) |
Reference pages: heapq, bisect, collections, and the Python wiki’s time complexity table for built-in operations.
Blind 75 vs NeetCode 150 vs Grind 75 vs LeetCode 75
| List | Size | Made by | Strength | Watch out for |
|---|---|---|---|---|
| Blind 75 (this repo) | 75 | Yangshun Tay, posted on Blind | The classic: short, covers every core pattern once | 6 Premium problems; fixed order; no priority between problems |
| Grind 75 | 75 by default, up to 169 | Yangshun Tay | Week-by-week schedule you can size to your available hours; the default 75 has no Premium problems | Different problem mix from Blind 75, so the two overlap but are not the same |
| NeetCode 150 | 150 | NeetCode | Every Blind 75 problem plus 75 more, grouped by pattern, with a video for each | Twice the time; best if you have 2-3 months |
| LeetCode 75 | 75 | LeetCode (official study plan) | Free, tracks progress on LeetCode, gentler problems | Lighter on hard graphs and DP than Blind 75 |
| Top Interview 150 | 150 | LeetCode (official study plan) | Broad, well-organised by topic | Long; more array/string drills |
| LeetCode Patterns | ~180 | Sean Prashad | Filter by pattern and company tags | No fixed order |
Best pick: If you have under a month, do the Blind 75 (or Grind 75 with your hours). If you have two months or more, do NeetCode 150, which contains the Blind 75, and use this repo for quick Python reviews of the core 75.
Common mistakes
- Reading the solution after five minutes. The struggle is where the pattern sticks. Give it 25-40 minutes, then read only the key insight.
- Solving once and moving on. Redo the problems you needed help with. Most people forget a solution within a week if they never retrieve it.
- Ignoring edge cases. Empty input, a single element, duplicates, negative numbers, integer overflow (in languages other than Python), and disconnected graphs.
- Mutating input you did not own. Number of Islands is commonly solved by overwriting the grid. Say so in an interview, or copy it, as this repo does.
- Validate BST with only parent comparisons. A node must respect every ancestor’s bound, not just its parent’s.
- Forgetting the visited set in graphs. Clone Graph and Course Schedule both loop forever on cycles without it.
- Using
list.pop(0)as a queue. It is O(n). Usecollections.deque. - Writing Python ints for bit problems as if they were 32-bit. Python integers are unbounded, so Sum of Two Integers needs a mask (see
solutions/binary.py). - Not saying the complexity. Interviewers almost always ask. Practise saying it for every problem.
Running the solutions and tests
Requires Python 3.8 or newer. No packages to install.
git clone https://github.com/Ralpberry-Labs/blind-75-leetcode-solutions.git
cd blind-75-leetcode-solutions
python3 -m unittest discover -s tests -t . -v
solutions/
structures.py ListNode, TreeNode, GraphNode and builders used by tests
array.py Array (10)
binary.py Binary (5)
dynamic_programming.py Dynamic Programming (11) + Combination Sum (LC 39) bonus
graph.py Graph (8)
interval.py Interval (5)
linked_list.py Linked List (6)
matrix.py Matrix (4)
string.py String (10)
tree.py Tree (14, including the trie problems)
heap.py Heap (2 + Merge k Sorted Lists from linked_list.py)
tests/
test_array_binary_dp.py
test_graph_interval_list_matrix.py
test_string_tree_heap.py
The tests use LeetCode’s public examples plus extra edge cases (empty inputs, single elements, cycles, negative numbers). Use them as a harness: replace a function body with your own attempt and run the tests.
FAQ
Is the Blind 75 still enough in 2027? It is enough to learn the core patterns, and that is what most coding rounds test. Interview questions have drifted a little harder and more “practical” (simulation, design-a-data-structure, follow-up questions), so after the 75, add a mix of newer Medium problems or move on to NeetCode 150 or Grind 169.
How long does the Blind 75 take? For most people, 40-80 hours: roughly 30-60 minutes per problem the first time, plus review. The schedules above spread that over 3-8 weeks.
Should I do Blind 75 or NeetCode 150? NeetCode 150 includes all of the Blind 75. Start with the 75; if you finish with time left, continue with the other 75 NeetCode problems.
Do I need LeetCode Premium for the Blind 75? No. Six problems are Premium on LeetCode, and all six have free equivalents on LintCode (table above).
Why Python? It is short, readable and accepted almost everywhere, so the idea is not buried in syntax. The key insights apply to any language.
What if I cannot solve the Easy problems? Normal at the start. Spend extra time on week 1, read the key insight sooner, and re-solve each problem from memory the next day. It gets faster.
Should I memorise solutions? Memorise templates (binary search bounds, BFS, topological sort, union-find, backtracking). Do not memorise full answers; interviewers change details and ask follow-ups.
Are these the exact questions companies ask? No. The Blind 75 is a practice list of public LeetCode problems that cover common patterns. Companies write and rotate their own questions. Treat any list as practice for the patterns, not as a question bank.
In what order should I solve the categories? Arrays, strings and hashing first, then two pointers and sliding window, linked lists, trees, graphs, intervals, and DP last. The 8-week plan above follows that order.
Where to go next
- More problems by pattern: NeetCode 150 / NeetCode roadmap and NeetCode’s Blind 75 video playlist on YouTube.
- Customised schedule: Grind 75 by the author of the Blind 75.
- Interview process and cheat sheets: the free Tech Interview Handbook.
- See algorithms move: VisuAlgo for animations and Python Tutor to step through your own code.
- Go deeper on algorithms: cp-algorithms for clear write-ups of graph, string and number-theory techniques.
- Complexity refresher: the Big-O Cheat Sheet.
- Official LeetCode study plans: LeetCode 75 and Top Interview 150.
- From Ralpberry Labs: a 150-problem plan in leetcode-150-study-plan and the pattern guide in leetcode-patterns.
Contributing
Pull requests are welcome:
- Found a bug or a clearer approach? Open an issue or PR. Every change to
solutions/needs a matching test intests/. - Run
python3 -m unittest discover -s tests -t .before you open a PR. - Keep key insights to one sentence and keep links pointing at the real LeetCode problem pages.
- Solutions in other languages are welcome in a separate folder (for example
solutions_js/) with their own tests.
The problem list belongs to its original author; the problem statements belong to LeetCode and are linked, not copied. The code and explanations here are original and MIT-licensed.
If this helped you, a star helps others find it.
More free resources
Part of the Ralpberry Labs open-source collection. See also Top 100 Open Source.