DSA Handbook

#Problem index

Every problem from the pattern pages, in one place. Roughly 110 problems — which is deliberate: a hundred problems you can re-derive beats three hundred you have seen.


#How to track this

Not with ticks. Ticks measure exposure; interviews measure recall.

Keep four columns per problem:

ColumnMeaning
SolvedGot it inside the 25-minute box, unaided
Help level0 = unaided … 6 = read the full solution (see how to practise)
Day 7Re-derived a week later, from a blank file
Day 30Re-derived a month later

The number that predicts interview performance is the day-7 column. A problem solved once and never revisited is not knowledge, it is a memory of having been told something.

A workable minimum: a spreadsheet with problem, pattern, date, help_level, day7, day30. Sort by help_level descending to find what to revisit.


Interactive simulation — needs JavaScript.


#The core 40

If time is short, these forty cover the highest-frequency ground. Marked ⭐ are the ones most likely to appear verbatim.

#ProblemLCPattern
1⭐ Two Sum1Hashing
2Contains Duplicate217Hashing
3Valid Anagram242Hashing
4⭐ Group Anagrams49Hashing
5Top K Frequent Elements347Hashing / heap
6⭐ Subarray Sum Equals K560Prefix sum
7Longest Consecutive Sequence128Hashing
8Valid Palindrome125Two pointers
9Two Sum II167Two pointers
10⭐ 3Sum15Two pointers
11⭐ Container With Most Water11Two pointers
12Trapping Rain Water42Two pointers
13⭐ Longest Substring Without Repeating3Sliding window
14Longest Repeating Character Replacement424Sliding window
15Permutation in String567Sliding window
16Minimum Size Subarray Sum209Sliding window
17⭐ Minimum Window Substring76Sliding window
18Sliding Window Maximum239Deque
19⭐ Valid Parentheses20Stack
20Min Stack155Stack
21⭐ Daily Temperatures739Monotonic stack
22Largest Rectangle in Histogram84Monotonic stack
23⭐ Binary Search704Binary search
24⭐ Search in Rotated Sorted Array33Binary search
25Find Minimum in Rotated Sorted Array153Binary search
26⭐ Koko Eating Bananas875Search on the answer
27Split Array Largest Sum410Search on the answer
28⭐ Maximum Depth of Binary Tree104Trees
29⭐ Binary Tree Level Order Traversal102Trees / BFS
30⭐ Validate BST98Trees
31⭐ Lowest Common Ancestor236Trees
32Binary Tree Maximum Path Sum124Trees
33⭐ Number of Islands200Graphs
34⭐ Rotting Oranges994Multi-source BFS
35⭐ Course Schedule207Topological sort
36Pacific Atlantic Water Flow417Graphs
37⭐ Kth Largest Element215Heap
38Merge k Sorted Lists23Heap
39⭐ Merge Intervals56Intervals
40⭐ Meeting Rooms II253Intervals / heap

The 21 starred problems are the ones I would guarantee you see across a handful of loops. If you can do only twenty things, do those.


#By pattern

#Hashing → [page](hashing.html)

LevelProblems
EasyTwo Sum (1) · Contains Duplicate (217) · Valid Anagram (242) · Majority Element (169)
MediumGroup Anagrams (49) · Top K Frequent (347) · Subarray Sum Equals K (560) · Longest Consecutive (128) · Contiguous Array (525) · 4Sum II (454)
HardFirst Missing Positive (41) · LRU Cache (146)

#Two pointers → [page](two-pointers.html)

LevelProblems
EasyValid Palindrome (125) · Two Sum II (167) · Remove Duplicates (26) · Merge Sorted Array (88)
Medium3Sum (15) · 3Sum Closest (16) · Container With Most Water (11) · Sort Colors (75) · Linked List Cycle II (142) · 4Sum (18) · Boats to Save People (881)
HardTrapping Rain Water (42)

#Sliding window → [page](sliding-window.html)

LevelProblems
EasyMaximum Average Subarray (643) · Contains Duplicate II (219)
MediumLongest Substring Without Repeating (3) · Longest Repeating Char Replacement (424) · Permutation in String (567) · Minimum Size Subarray Sum (209) · Fruit Into Baskets (904) · Max Consecutive Ones III (1004) · At Most K Distinct (340) · Subarrays with K Different (992)
HardMinimum Window Substring (76) · Sliding Window Maximum (239)

#Stack → [page](stack.html)

LevelProblems
EasyValid Parentheses (20) · Min Stack (155) · Baseball Game (682) · Remove Adjacent Duplicates (1047)
MediumDaily Temperatures (739) · Next Greater Element II (503) · Evaluate RPN (150) · Asteroid Collision (735) · Simplify Path (71) · Decode String (394) · Car Fleet (853) · Online Stock Span (901)
HardLargest Rectangle (84) · Maximal Rectangle (85)

#Binary search → [page](binary-search.html)

LevelProblems
EasyBinary Search (704) · Search Insert Position (35) · First Bad Version (278)
MediumFirst and Last Position (34) · Search in Rotated Array (33) · Find Minimum in Rotated (153) · Koko Eating Bananas (875) · Capacity To Ship (1011) · Split Array Largest Sum (410) · Search a 2D Matrix (74) · Find Peak Element (162) · Time Based Store (981)
HardMedian of Two Sorted Arrays (4) · Min Max Distance to Gas Station (774)

#Trees → [page](trees.html)

LevelProblems
EasyMax Depth (104) · Invert Tree (226) · Same Tree (100) · Symmetric Tree (101) · Diameter (543)
MediumLevel Order (102) · Validate BST (98) · LCA (236) · LCA of BST (235) · Kth Smallest in BST (230) · Construct from Pre+In (105) · Right Side View (199) · Path Sum II (113)
HardMax Path Sum (124) · Serialise/Deserialise (297)

#Graphs → [page](graphs.html)

LevelProblems
EasyNumber of Islands (200) · Flood Fill (733) · Max Area of Island (695)
MediumRotting Oranges (994) · Course Schedule (207) · Course Schedule II (210) · Clone Graph (133) · Pacific Atlantic (417) · Number of Provinces (547) · Surrounded Regions (130) · Word Ladder (127) · Redundant Connection (684) · Network Delay Time (743)
HardAlien Dictionary (269) · Word Ladder II (126) · Swim in Rising Water (778)

#Heap → [page](heap.html)

LevelProblems
EasyKth Largest in Stream (703) · Last Stone Weight (1046)
MediumTop K Frequent (347) · Kth Largest in Array (215) · K Closest Points (973) · Task Scheduler (621) · Reorganise String (767) · Meeting Rooms II (253) · Design Twitter (355)
HardFind Median from Stream (295) · Merge k Sorted Lists (23) · Smallest Range (632)

#Intervals → [page](intervals.html)

LevelProblems
EasyMeeting Rooms (252) · Summary Ranges (228)
MediumMerge Intervals (56) · Insert Interval (57) · Non-overlapping (435) · Meeting Rooms II (253) · Minimum Arrows (452) · Interval Intersections (986) · Car Pooling (1094)
HardEmployee Free Time (759)

#Dynamic programming → [page](dynamic-programming.html)

LevelProblems
EasyClimbing Stairs (70) · Min Cost Climbing Stairs (746) · House Robber (198) · House Robber II (213)
MediumCoin Change (322) · Coin Change II (518) · LIS (300) · LCS (1143) · Word Break (139) · Unique Paths (62) · Partition Equal Subset (416) · Max Product Subarray (152) · Decode Ways (91)
HardEdit Distance (72) · Burst Balloons (312) · Regex Matching (10)

#Suggested order across patterns

Do not work down one pattern to completion before starting the next. Interleave, because interleaving is what builds the recognition that the interview tests.

   week 1   hashing easy+medium        two pointers easy
   week 2   two pointers medium        sliding window easy+medium
   week 3   binary search all          REVIEW week 1
   week 4   trees easy+medium          stack easy+medium
   week 5   graphs easy+medium         heap easy+medium
   week 6   REVIEW everything          intervals
   week 7   DP easy+medium             hard problems from earlier patterns
   week 8   REVIEW + mocks

Two review weeks in eight is not generous, it is the minimum. Skipping them to cover more patterns is how people reach week eight having forgotten week one.


#When you are ready

Not "when the list is finished". These:

  • The 21 starred problems, re-derivable cold in under 25 minutes each
  • Ten unseen problems, pattern named correctly for eight, in under 60s each
  • Templates for binary search, BFS, DFS and the monotonic stack typed from memory
  • At least three mock interviews completed, out loud, with a human