You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Parameters and arguments (by value vs by reference)
Return types and multiple returns
Recursion basics
Lambda functions / Anonymous functions
3. Built-in Data Structures
Arrays (static vs dynamic)
Strings and string manipulation
Lists / ArrayLists / Vectors
Dictionaries / HashMaps / Objects
Sets and their operations
4. Object-Oriented Programming (OOP)
Classes and objects
Constructors and destructors
Encapsulation (public, private, protected)
Inheritance and polymorphism
Abstraction and interfaces
1.2 Mathematics for DSA
1.2.1 Number Theory
Prime Numbers
Definition: A number > 1 that has no positive divisors other than 1 and itself
Key Concepts:
- Prime checking: O(√n) complexity
- Sieve of Eratosthenes: Find all primes up to n in O(n log log n)
- Prime factorization
Essential Problems:
Check if a number is prime
Find all primes up to N (Sieve of Eratosthenes)
Count prime factors of a number
Find GCD and LCM of two numbers
GCD and LCM
GCD (Greatest Common Divisor): Largest number that divides both a and b
- Euclidean Algorithm: GCD(a, b) = GCD(b, a % b), base case: GCD(a, 0) = a
LCM (Least Common Multiple): Smallest number divisible by both a and b
- LCM(a, b) = (a × b) / GCD(a, b)
Modular Arithmetic
Key Properties:
- (a + b) % m = ((a % m) + (b % m)) % m
- (a - b) % m = ((a % m) - (b % m) + m) % m
- (a × b) % m = ((a % m) × (b % m)) % m
- (a / b) % m = (a × b^(-1)) % m (requires modular inverse)
Modular Exponentiation: Calculate a^b % m efficiently in O(log b)
Fundamental Concepts:
- Probability = Favorable outcomes / Total outcomes
- P(A or B) = P(A) + P(B) - P(A and B)
- P(A and B) = P(A) × P(B) if independent
- Expected Value = Σ (value × probability)
1.3 Complexity Analysis (Big O Notation)
Understanding Time Complexity
What is Big O?
Big O notation describes the upper bound of an algorithm's growth rate. It tells us how the runtime/space grows as input size increases.
Common Time Complexities (Fastest to Slowest)
Notation
Name
Example
n=100 ops
O(1)
Constant
Array access
1
O(log n)
Logarithmic
Binary search
7
O(n)
Linear
Array traversal
100
O(n log n)
Linearithmic
Merge sort
664
O(n²)
Quadratic
Bubble sort
10,000
O(n³)
Cubic
3 nested loops
1,000,000
O(2^n)
Exponential
Subsets generation
10^30
O(n!)
Factorial
Permutations
10^157
Complexity Analysis Rules
1. DROP CONSTANTS:
O(2n) → O(n)
O(100n + 50) → O(n)
2. DROP LOWER ORDER TERMS:
O(n² + n) → O(n²)
O(n³ + n²+ n) → O(n³)
3. MULTIPLICATION FOR NESTED OPERATIONS:
for i in range(n): # O(n)
for j in range(m): # O(m)
print(i, j) # × O(1)
# Total: O(n × m)
4. ADDITION FOR SEQUENTIAL OPERATIONS:
for i in range(n): pass # O(n)
for j in range(m): pass # O(m)
# Total: O(n + m)
Space Complexity
Measures additional memory used by the algorithm
Examples:
- Variables: O(1)
- Array of size n: O(n)
- 2D array n×m: O(n×m)
- Recursion depth d: O(d) for call stack
- HashMap with n keys: O(n)
Constraint Analysis (Crucial for Interviews!)
Use constraints to determine acceptable complexity:
n ≤ 10 → O(n!), O(2^n) acceptable
n ≤ 20 → O(2^n), O(n! × log n) possible
n ≤ 100 → O(n³) acceptable
n ≤ 1,000 → O(n²) acceptable
n ≤ 10,000 → O(n²) borderline, prefer O(n log n)
n ≤ 100,000 → O(n log n) or O(n) needed
n ≤ 1,000,000 → O(n) or O(n log n) required
n ≤ 10^8 → O(n) maximum, prefer O(log n) or O(1)
1.4 Recursion Fundamentals
What is Recursion?
A function that calls itself to solve smaller instances of the same problem.
Two Essential Parts:
1. BASE CASE: Condition to stop recursion (prevents infinite loop)
2. RECURSIVE CASE: Break problem into smaller subproblems
Anatomy of a Recursive Function
defrecursive_function(input):
# BASE CASE - when to stopifbase_condition:
returnbase_value# RECURSIVE CASE - make progress toward base caseresult=recursive_function(smaller_input)
# COMBINE - use result to build answerreturncombined_result
deffibonacci(n):
ifn<=1: # Base casereturnnreturnfibonacci(n-1) +fibonacci(n-2) # Recursive case# Time: O(2^n) - Exponential! (can be optimized with memoization)
3. Sum of Array
defarray_sum(arr, n):
ifn==0: # Base casereturn0returnarr[n-1] +array_sum(arr, n-1)
4. Power Function
defpower(x, n):
ifn==0: # Base casereturn1ifn%2==0: # Even exponenthalf=power(x, n//2)
returnhalf*halfelse: # Odd exponentreturnx*power(x, n-1)
# Time: O(log n) - Much better than O(n)!
Recursion Patterns
Pattern 1: Decrease and Conquer
Reduce problem size by constant factor each step
Examples: Factorial, Linear search, Array sum
Pattern 2: Divide and Conquer
Split problem into multiple subproblems, solve each, combine results
Examples: Merge sort, Quick sort, Binary search
Pattern 3: Multiple Recursion
Make multiple recursive calls at each step
Examples: Fibonacci, Tree traversals, Combinations
Recursion vs Iteration Trade-offs
Aspect
Recursion
Iteration
Code readability
Often cleaner
Can be verbose
Space
O(depth) stack
Usually O(1)
Performance
Overhead from calls
Generally faster
Use when
Problem is naturally recursive
Performance critical
Tail Recursion Optimization
# NOT tail recursive (computation after recursive call)deffactorial(n):
ifn<=1: return1returnn*factorial(n-1) # Multiplication happens after call# TAIL RECURSIVE (recursive call is last operation)deffactorial_tail(n, accumulator=1):
ifn<=1: returnaccumulatorreturnfactorial_tail(n-1, n*accumulator) # Nothing after call
1.5 Practice Problems for Phase 1
Beginner Level (Complete All)
#
Problem
Concept
Platform
1
Two Sum
Arrays, HashMap basics
LeetCode #1
2
Palindrome Number
Math, string manipulation
LeetCode #9
3
Roman to Integer
String parsing
LeetCode #13
4
Valid Parentheses
Stack basics
LeetCode #20
5
Merge Two Sorted Lists
Linked list basics
LeetCode #21
6
Remove Duplicates from Sorted Array
Two pointers
LeetCode #26
7
Search Insert Position
Binary search basics
LeetCode #35
8
Maximum Subarray
Kadane's algorithm intro
LeetCode #53
9
Climbing Stairs
Basic recursion/DP
LeetCode #70
10
Sqrt(x)
Binary search application
LeetCode #69
Recursion Practice
#
Problem
Concept
1
Reverse a string using recursion
Basic recursion
2
Check if array is sorted
Decrease and conquer
3
Print 1 to N without loop
Head recursion
4
Print N to 1 without loop
Tail recursion
5
Sum of digits
Number manipulation
6
Power of three/four
Multiple bases
7
Fibonacci with memoization
Intro to DP
8
Count ways to reach nth stair
Counting problems
Math Practice
#
Problem
Platform
1
Count Primes
LeetCode #204
2
Power of Two
LeetCode #231
3
Ugly Number
LeetCode #263
4
Happy Number
LeetCode #202
5
Excel Sheet Column Number
LeetCode #171
6
Factorial Trailing Zeroes
LeetCode #172
Phase 1 Checklist
Chose programming language and practiced syntax
Comfortable with loops, conditions, functions
Understand OOP basics (classes, inheritance)
Know prime checking and Sieve algorithm
Can calculate GCD/LCM efficiently
Understand modular arithmetic
Know permutation and combination formulas
Can analyze time complexity of code
Can analyze space complexity of code
Can estimate required complexity from constraints
Understand recursion base and recursive cases
Solved at least 10 easy recursion problems
Completed all 10 beginner level problems
Can trace through recursive calls mentally
Estimated Time: 2-3 weeks with 2-3 hours daily practice
Duration: 4-6 weeks | Goal: Master every fundamental data structure
2.1 Arrays
What is an Array?
A contiguous block of memory storing elements of the same type, accessed by index.
Array Operations & Complexities
Operation
Time Complexity
Notes
Access by index
O(1)
Direct memory access
Search (unsorted)
O(n)
Linear scan required
Search (sorted)
O(log n)
Binary search
Insert at end
O(1) amortized
May need resize
Insert at index
O(n)
Shift elements right
Delete at end
O(1)
Simple removal
Delete at index
O(n)
Shift elements left
Key Array Patterns
Pattern 1: Two Pointers
Use two pointers moving towards each other or in same direction
Applications:
- Pair sum problems
- Reversing arrays
- Removing duplicates
- Merging sorted arrays
- Partitioning (Dutch National Flag)
Example: Two Sum (Sorted Array)
left = 0, right = n-1
while left < right:
sum = arr[left] + arr[right]
if sum == target: return [left, right]
elif sum < target: left++
else: right--
Pattern 2: Sliding Window
Maintain a window that slides over the array
Types:
1. Fixed size window (easy)
2. Variable size window (medium-hard)
Template (Variable Window):
left = 0
for right in range(n):
# Add arr[right] to window
while window_condition_invalid():
# Remove arr[left] from window
left++
# Update answer
Pattern 3: Prefix Sum
Precompute cumulative sums for O(1) range queries
prefix[i] = sum of arr[0...i-1]
sum(i, j) = prefix[j+1] - prefix[i]
2D Prefix Sum:
prefix[i][j] = sum of submatrix from (0,0) to (i-1,j-1)
Pattern 4: Kadane's Algorithm
Find maximum subarray sum in O(n)
max_ending_here = max_so_far = arr[0]
for i in range(1, n):
max_ending_here = max(arr[i], max_ending_here + arr[i])
max_so_far = max(max_so_far, max_ending_here)
Must-Solve Array Problems
#
Problem
Pattern
Difficulty
1
Two Sum
HashMap
Easy
2
Best Time to Buy/Sell Stock
Single pass
Easy
3
Contains Duplicate
HashSet
Easy
4
Product of Array Except Self
Prefix/Suffix
Medium
5
Maximum Subarray
Kadane's
Medium
6
Maximum Product Subarray
DP variant
Medium
7
3Sum
Two pointers
Medium
8
Container With Most Water
Two pointers
Medium
9
Merge Intervals
Sorting
Medium
10
Subarray Sum Equals K
Prefix sum + HashMap
Medium
11
Rotate Array
Reversal
Medium
12
First Missing Positive
Cyclic sort
Hard
13
Trapping Rain Water
Two pointers/Stack
Hard
14
Median of Two Sorted Arrays
Binary search
Hard
2.2 Strings
String Fundamentals
Strings = Arrays of characters with special operations
Key Properties:
- Immutable in most languages (Java, Python)
- Comparison is O(min(len(s1), len(s2)))
- Concatenation: O(n) for immutable strings
String Builder Usage:
When doing many concatenations, use StringBuilder (Java)
or list join (Python) for O(n) instead of O(n²)
String Patterns
Pattern 1: Character Frequency Map
fromcollectionsimportCounterfreq=Counter(s) # O(n) to build, O(1) to query# Check anagramdefis_anagram(s1, s2):
returnCounter(s1) ==Counter(s2)
Find substrings with specific properties
- Longest substring without repeating chars
- Minimum window substring
- Anagram substrings
Pattern 4: String Matching
KMP Algorithm: O(n + m) pattern matching
Rabin-Karp: O(n + m) average with rolling hash
Z-Algorithm: O(n + m) pattern matching
Must-Solve String Problems
#
Problem
Pattern
Difficulty
1
Valid Anagram
Frequency count
Easy
2
Valid Palindrome
Two pointers
Easy
3
Longest Common Prefix
Vertical/Horizontal
Easy
4
Longest Substring Without Repeating
Sliding window
Medium
5
Longest Palindromic Substring
Expand from center/DP
Medium
6
Group Anagrams
Hash sorting
Medium
7
Minimum Window Substring
Sliding window
Hard
8
Palindromic Substrings
DP/Expand
Medium
9
Encode and Decode Strings
Design
Medium
10
Edit Distance
DP
Medium
2.3 Linked Lists
What is a Linked List?
Sequential collection where each element (node) contains data and reference to next node.
Types of Linked Lists
1. SINGLY LINKED LIST
[data|next] → [data|next] → [data|null]
- Each node points to next
- Traverse forward only
2. DOUBLY LINKED LIST
null ← [prev|data|next] ⟷ [prev|data|next] → null
- Each node points to prev and next
- Traverse both directions
3. CIRCULAR LINKED LIST
[data|next] → [data|next] → [data|next] ⟲
- Last node points to first
- No null terminator
# Use dummy when head might changedefremove_elements(head, val):
dummy=ListNode(0)
dummy.next=headcurr=dummywhilecurr.next:
ifcurr.next.val==val:
curr.next=curr.next.nextelse:
curr=curr.nextreturndummy.next
Must-Solve Linked List Problems
#
Problem
Pattern
Difficulty
1
Reverse Linked List
Reversal
Easy
2
Merge Two Sorted Lists
Merge
Easy
3
Linked List Cycle
Fast/Slow
Easy
4
Middle of Linked List
Fast/Slow
Easy
5
Remove Nth Node From End
Two pointers
Medium
6
Add Two Numbers
Math
Medium
7
Reorder List
Find mid + Reverse + Merge
Medium
8
Linked List Cycle II
Floyd's
Medium
9
LRU Cache
HashMap + DLL
Medium
10
Merge k Sorted Lists
Heap/Divide-conquer
Hard
11
Reverse Nodes in k-Group
Reversal
Hard
2.4 Stacks
What is a Stack?
LIFO (Last In, First Out) data structure.
Operations:
- push(x): Add to top - O(1)
- pop(): Remove from top - O(1)
- peek/top(): View top - O(1)
- isEmpty(): Check empty - O(1)
Visualization:
| 3 | ← top
| 2 |
| 1 |
-------
Data structure that maps keys to values using a hash function.
Key Concepts:
- Hash Function: Converts key to index
- Collision Resolution: Handle same index for different keys
- Chaining: Linked list at each bucket
- Open Addressing: Probe for next empty slot
- Load Factor: n/capacity, typically resize at 0.75
1 ← Root
/ \
2 3 ← Internal nodes
/ \ \
4 5 6 ← Leaf nodes
- Root: Top node with no parent
- Parent: Node with children
- Child: Node with parent
- Leaf: Node with no children
- Height: Longest path from root to leaf
- Depth: Distance from root to node
- Subtree: Tree formed by node and descendants
Binary Tree
Each node has at most 2 children (left and right)
Types:
1. Full Binary Tree: Every node has 0 or 2 children
2. Complete Binary Tree: All levels filled except last, filled left to right
3. Perfect Binary Tree: All internal nodes have 2 children, all leaves same level
4. Balanced Binary Tree: Height difference of subtrees ≤ 1
Properties:
- Left subtree contains only nodes < root
- Right subtree contains only nodes > root
- Both subtrees are also BSTs
Operations:
| Operation | Average | Worst (unbalanced) |
|-----------|---------|-------------------|
| Search | O(log n) | O(n) |
| Insert | O(log n) | O(n) |
| Delete | O(log n) | O(n) |
Self-Balancing Trees (Know concepts)
AVL Tree:
- Height difference of subtrees ≤ 1
- Rotations to maintain balance
Red-Black Tree:
- Every node is red or black
- Root is black
- Red nodes can't have red children
- Same black nodes on all paths
Must-Solve Tree Problems
#
Problem
Pattern
Difficulty
1
Maximum Depth of Binary Tree
DFS
Easy
2
Invert Binary Tree
DFS
Easy
3
Same Tree
DFS
Easy
4
Symmetric Tree
DFS
Easy
5
Binary Tree Level Order
BFS
Medium
6
Validate BST
Inorder/Bounds
Medium
7
Lowest Common Ancestor (BST)
BST property
Medium
8
Binary Tree Right Side View
BFS
Medium
9
Construct Binary Tree from Preorder/Inorder
Divide & Conquer
Medium
10
Kth Smallest Element in BST
Inorder
Medium
11
Serialize and Deserialize Binary Tree
BFS/DFS
Hard
12
Binary Tree Maximum Path Sum
DFS
Hard
2.8 Heaps (Priority Queues)
What is a Heap?
Complete binary tree satisfying heap property.
Max Heap: Parent ≥ Children
Min Heap: Parent ≤ Children
Array Representation (0-indexed):
- Parent of i: (i-1) // 2
- Left child of i: 2*i + 1
- Right child of i: 2*i + 2
Example Min Heap:
1
/ \
3 2
/ \
5 4
Array: [1, 3, 2, 5, 4]
deffind_k_largest(nums, k):
returnheapq.nlargest(k, nums)
# Or with min heap of size k:deffind_k_largest_v2(nums, k):
heap=nums[:k]
heapq.heapify(heap)
fornuminnums[k:]:
ifnum>heap[0]:
heapq.heapreplace(heap, num)
returnheap
- Vertex (Node): Point in graph
- Edge: Connection between vertices
- Directed: Edges have direction (A → B)
- Undirected: Edges are bidirectional (A — B)
- Weighted: Edges have values
- Cycle: Path that starts and ends at same vertex
- Connected: Path exists between all vertex pairs
- DAG: Directed Acyclic Graph
defmax_sum_k(arr, k):
"""Maximum sum of subarray of size k"""window_sum=sum(arr[:k])
max_sum=window_sumforiinrange(k, len(arr)):
window_sum+=arr[i] -arr[i-k] # Slide windowmax_sum=max(max_sum, window_sum)
returnmax_sum
Variable Size Window Template
defsliding_window_variable(arr, condition):
"""Find min/max window satisfying condition"""left=0result=0# or float('inf') for minimum# window_state = ... # Track window stateforrightinrange(len(arr)):
# 1. ADD element at right to window# window_state.add(arr[right])# 2. SHRINK window while invalidwhilenotis_valid(window_state):
# Remove element at left# window_state.remove(arr[left])left+=1# 3. UPDATE resultresult=max(result, right-left+1)
returnresult
Example: Longest Substring Without Repeating Characters
Given items with weight and value, maximize value within capacity
State: dp[i][w] = max value using items[0:i] with capacity w
Transition:
- Skip item: dp[i][w] = dp[i-1][w]
- Take item: dp[i][w] = dp[i-1][w-weight[i]] + value[i]
- dp[i][w] = max(skip, take)
State: dp[i][j] = property of substring s[i:j]
Transition: Depends on problem
Examples: Palindrome Partitioning, Longest Palindromic Substring
Pattern 6: Interval DP
State: dp[i][j] = optimal answer for range [i, j]
Transition: Try all split points k in [i, j]
Examples: Matrix Chain Multiplication, Burst Balloons
DP Problem-Solving Framework
1. IDENTIFY: Is this a DP problem? (Optimization/Counting with subproblems)
2. DEFINE STATE: What does dp[i] or dp[i][j] represent?
- What information uniquely identifies a subproblem?
- What parameters change as we solve?
3. RECURRENCE: How to compute dp[i] from smaller subproblems?
- What are the choices at each step?
- How do subproblems combine?
4. BASE CASE: What are the trivial cases?
- dp[0] = ?, dp[1] = ?
5. ORDER: In what order to fill the table?
- Must solve subproblems before main problem
6. ANSWER: Where is the final answer?
- dp[n]? dp[n][m]? max(dp[i])?
Must-Solve DP Problems
1D DP (Start here)
#
Problem
Pattern
Difficulty
1
Climbing Stairs
Fibonacci-like
Easy
2
House Robber
Linear decision
Medium
3
House Robber II
Circular array
Medium
4
Decode Ways
Counting
Medium
5
Longest Increasing Subsequence
LIS
Medium
6
Maximum Product Subarray
Kadane variant
Medium
7
Word Break
String DP
Medium
2D DP
#
Problem
Pattern
Difficulty
8
Unique Paths
Grid
Medium
9
Unique Paths II
Grid with obstacles
Medium
10
Minimum Path Sum
Grid
Medium
11
Longest Common Subsequence
Two strings
Medium
12
Edit Distance
Two strings
Medium
13
Target Sum
0/1 Knapsack
Medium
Knapsack Variants
#
Problem
Pattern
Difficulty
14
Coin Change
Unbounded
Medium
15
Coin Change 2
Counting
Medium
16
Partition Equal Subset Sum
0/1 Knapsack
Medium
17
Perfect Squares
Unbounded
Medium
Advanced
#
Problem
Pattern
Difficulty
18
Longest Palindromic Subsequence
Interval
Medium
19
Interleaving String
Two strings
Medium
20
Regular Expression Matching
Two strings
Hard
21
Burst Balloons
Interval
Hard
3.6 Greedy Algorithms
The Core Idea
Make locally optimal choice at each step, hoping for global optimum.
When Greedy Works
Optimal substructure
Greedy choice property (local optimum leads to global optimum)
Can prove correctness (exchange argument, induction)
Purpose: Prefix sums with updates in O(log n), simpler than segment tree
classFenwickTree:
def__init__(self, n):
self.n=nself.tree= [0] * (n+1)
defupdate(self, i, delta):
"""Add delta to index i"""i+=1# 1-indexedwhilei<=self.n:
self.tree[i] +=deltai+=i& (-i) # Add lowest set bitdefprefix_sum(self, i):
"""Sum of elements [0, i]"""i+=1# 1-indexedtotal=0whilei>0:
total+=self.tree[i]
i-=i& (-i) # Remove lowest set bitreturntotaldefrange_sum(self, l, r):
"""Sum of elements [l, r]"""returnself.prefix_sum(r) - (self.prefix_sum(l-1) ifl>0else0)
4.3 Bit Manipulation
Essential Bit Operations
# Basicsx&y# ANDx|y# ORx^y# XOR~x# NOTx<<n# Left shift (multiply by 2^n)x>>n# Right shift (divide by 2^n)# Common Tricksx&1# Check if oddx& (x-1) # Remove lowest set bitx& (-x) # Isolate lowest set bitx| (x+1) # Set lowest unset bitx^ (1<<i) # Toggle bit ix| (1<<i) # Set bit ix&~(1<<i) # Clear bit i
(x>>i) &1# Get bit i
Important Bit Manipulation Patterns
Count Set Bits (Brian Kernighan)
defcount_bits(n):
count=0whilen:
n&= (n-1) # Remove lowest set bitcount+=1returncount
Quality > Quantity: Deep understanding of 200 problems > surface level of 500
Time yourself: Practice under interview conditions
Time Allocation Per Problem
Difficulty
Time Limit
Review Solution
Easy
15-20 min
After 15 min stuck
Medium
30-40 min
After 25 min stuck
Hard
45-60 min
After 40 min stuck
5.2 The 200 Essential Problems Roadmap
Week 1-2: Arrays & Hashing (20 problems)
#
Problem
Topics
1
Two Sum
HashMap
2
Contains Duplicate
HashSet
3
Valid Anagram
Frequency
4
Group Anagrams
HashMap
5
Top K Frequent Elements
Heap/Bucket
6
Product of Array Except Self
Prefix
7
Longest Consecutive Sequence
HashSet
8
Valid Sudoku
HashSet
9
Encode and Decode Strings
Design
10
Subarray Sum Equals K
Prefix + HashMap
11
Maximum Subarray
Kadane's
12
Maximum Product Subarray
DP
13
3Sum
Two Pointers
14
Container With Most Water
Two Pointers
15
Trapping Rain Water
Two Pointers
16
Move Zeroes
Two Pointers
17
Sort Colors
Dutch Flag
18
Merge Intervals
Sorting
19
Insert Interval
Sorting
20
First Missing Positive
Cyclic Sort
Week 3-4: Two Pointers & Sliding Window (15 problems)
#
Problem
Topics
1
Valid Palindrome
Two Pointers
2
Two Sum II (Sorted)
Two Pointers
3
3Sum
Two Pointers
4
Container With Most Water
Two Pointers
5
Best Time to Buy/Sell Stock
Sliding Window
6
Longest Substring Without Repeating
Sliding Window
7
Longest Repeating Character Replacement
Sliding Window
8
Permutation in String
Sliding Window
9
Minimum Window Substring
Sliding Window
10
Sliding Window Maximum
Deque
11
Remove Duplicates from Sorted Array
Two Pointers
12
Remove Element
Two Pointers
13
Next Permutation
Two Pointers
14
Find All Anagrams
Sliding Window
15
Fruit Into Baskets
Sliding Window
Week 5-6: Stack & Queue (15 problems)
#
Problem
Topics
1
Valid Parentheses
Stack
2
Min Stack
Design
3
Evaluate Reverse Polish Notation
Stack
4
Generate Parentheses
Backtracking
5
Daily Temperatures
Monotonic Stack
6
Car Fleet
Monotonic Stack
7
Largest Rectangle in Histogram
Monotonic Stack
8
Decode String
Stack
9
Asteroid Collision
Stack
10
Basic Calculator
Stack
11
Basic Calculator II
Stack
12
Implement Queue using Stacks
Design
13
Implement Stack using Queues
Design
14
Next Greater Element I
Monotonic Stack
15
Remove K Digits
Monotonic Stack
Week 7-8: Binary Search (15 problems)
#
Problem
Topics
1
Binary Search
Standard
2
Search a 2D Matrix
Standard
3
Search in Rotated Sorted Array
Modified
4
Find Minimum in Rotated Sorted Array
Boundary
5
Find Peak Element
Boundary
6
Search in Rotated Sorted Array II
Modified
7
Find First and Last Position
Lower/Upper Bound
8
Time Based Key-Value Store
Design
9
Koko Eating Bananas
Answer Search
10
Capacity To Ship Packages
Answer Search
11
Split Array Largest Sum
Answer Search
12
Median of Two Sorted Arrays
Partition
13
Find K Closest Elements
Binary Search
14
Single Element in Sorted Array
Modified
15
Random Pick with Weight
Prefix + BS
Week 9-10: Linked Lists (15 problems)
#
Problem
Topics
1
Reverse Linked List
Reversal
2
Merge Two Sorted Lists
Merge
3
Reorder List
Fast/Slow + Reversal
4
Remove Nth Node From End
Two Pointers
5
Copy List with Random Pointer
HashMap
6
Add Two Numbers
Math
7
Linked List Cycle
Fast/Slow
8
Linked List Cycle II
Floyd's
9
Find the Duplicate Number
Floyd's
10
LRU Cache
HashMap + DLL
11
LFU Cache
HashMap + DLL
12
Merge k Sorted Lists
Heap
13
Reverse Nodes in k-Group
Reversal
14
Swap Nodes in Pairs
Recursion
15
Palindrome Linked List
Fast/Slow
Week 11-13: Trees (25 problems)
#
Problem
Topics
1
Invert Binary Tree
DFS
2
Maximum Depth of Binary Tree
DFS
3
Same Tree
DFS
4
Subtree of Another Tree
DFS
5
Lowest Common Ancestor of BST
BST
6
Binary Tree Level Order Traversal
BFS
7
Binary Tree Right Side View
BFS
8
Count Good Nodes in Binary Tree
DFS
9
Validate Binary Search Tree
DFS
10
Kth Smallest Element in BST
Inorder
11
Construct Binary Tree from Traversals
Recursion
12
Binary Tree Maximum Path Sum
DFS
13
Serialize and Deserialize Binary Tree
BFS/DFS
14
Diameter of Binary Tree
DFS
15
Balanced Binary Tree
DFS
16
Path Sum
DFS
17
Path Sum II
Backtracking
18
Path Sum III
Prefix Sum
19
Binary Search Tree Iterator
Stack
20
Populating Next Right Pointers
BFS
21
Flatten Binary Tree to Linked List
DFS
22
Sum Root to Leaf Numbers
DFS
23
Binary Tree Zigzag Level Order
BFS
24
Lowest Common Ancestor
DFS
25
Delete Node in BST
BST
Week 14-16: Graphs (25 problems)
#
Problem
Topics
1
Number of Islands
DFS/BFS
2
Clone Graph
DFS/BFS
3
Max Area of Island
DFS
4
Pacific Atlantic Water Flow
DFS
5
Surrounded Regions
DFS/BFS
6
Rotting Oranges
Multi-source BFS
7
Walls and Gates
Multi-source BFS
8
Course Schedule
Topological Sort
9
Course Schedule II
Topological Sort
10
Redundant Connection
Union-Find
11
Number of Connected Components
Union-Find/DFS
12
Graph Valid Tree
Union-Find
13
Word Ladder
BFS
14
Alien Dictionary
Topological Sort
15
Network Delay Time
Dijkstra
16
Cheapest Flights K Stops
Modified BFS
17
Min Cost to Connect All Points
MST
18
Swim in Rising Water
Binary Search + BFS
19
Reconstruct Itinerary
Eulerian Path
20
Is Graph Bipartite
BFS/DFS
21
Shortest Path in Binary Matrix
BFS
22
Word Search
Backtracking
23
Word Search II
Trie + Backtracking
24
Open the Lock
BFS
25
Accounts Merge
Union-Find
Week 17-18: Heap & Priority Queue (12 problems)
#
Problem
Topics
1
Kth Largest Element
Quick Select/Heap
2
Last Stone Weight
Max Heap
3
K Closest Points to Origin
Min Heap
4
Kth Largest Element in Stream
Min Heap
5
Task Scheduler
Max Heap + Greedy
6
Find Median from Data Stream
Two Heaps
7
Merge k Sorted Lists
Min Heap
8
Top K Frequent Elements
Bucket/Heap
9
Sort Characters By Frequency
Heap
10
Reorganize String
Max Heap
11
Ugly Number II
Min Heap
12
Smallest Range Covering K Lists
Min Heap
Week 19-21: Dynamic Programming (30 problems)
#
Problem
Topics
1
Climbing Stairs
1D DP
2
Min Cost Climbing Stairs
1D DP
3
House Robber
1D DP
4
House Robber II
Circular 1D DP
5
Longest Palindromic Substring
2D DP
6
Palindromic Substrings
2D DP
7
Decode Ways
1D DP
8
Coin Change
Unbounded Knapsack
9
Coin Change II
Counting
10
Maximum Product Subarray
1D DP
11
Word Break
1D DP
12
Longest Increasing Subsequence
1D DP/BS
13
Partition Equal Subset Sum
0/1 Knapsack
14
Target Sum
0/1 Knapsack
15
Unique Paths
2D DP
16
Unique Paths II
2D DP
17
Longest Common Subsequence
2D DP
18
Edit Distance
2D DP
19
Interleaving String
2D DP
20
Distinct Subsequences
2D DP
21
Best Time to Buy/Sell Stock (all)
State DP
22
Maximal Square
2D DP
23
Jump Game
Greedy/DP
24
Jump Game II
Greedy/DP
25
Perfect Squares
Unbounded Knapsack
26
Regular Expression Matching
2D DP
27
Wildcard Matching
2D DP
28
Burst Balloons
Interval DP
29
Longest Valid Parentheses
1D DP
30
Russian Doll Envelopes
LIS
Week 22-23: Backtracking (15 problems)
#
Problem
Topics
1
Subsets
Generate
2
Subsets II
Generate + Skip
3
Permutations
Generate
4
Permutations II
Generate + Skip
5
Combination Sum
Unlimited
6
Combination Sum II
Limited
7
Combination Sum III
Constrained
8
Letter Combinations of Phone
Generate
9
Palindrome Partitioning
Partition
10
N-Queens
Constraint
11
N-Queens II
Counting
12
Sudoku Solver
Constraint
13
Word Search
Grid
14
Restore IP Addresses
Partition
15
Generate Parentheses
Valid Generate
Week 24: Greedy & Intervals (13 problems)
#
Problem
Topics
1
Maximum Subarray
Kadane's
2
Jump Game
Greedy
3
Jump Game II
Greedy
4
Gas Station
Circular Greedy
5
Hand of Straights
HashMap + Sort
6
Merge Triplets
Greedy
7
Partition Labels
Greedy
8
Valid Parenthesis String
Greedy
9
Merge Intervals
Sort
10
Insert Interval
Sort
11
Non-overlapping Intervals
Interval Schedule
12
Meeting Rooms
Sorting
13
Meeting Rooms II
Min Heap
5.3 Weekly Study Plan Template
MONDAY-WEDNESDAY: Learn new topic
- Read theory and patterns
- Study 2-3 example problems
- Solve 3-4 problems independently
THURSDAY-FRIDAY: Practice problems
- Solve 5-6 problems from that topic
- Mix easy and medium difficulty
SATURDAY: Review and hard problems
- Revisit problems you struggled with
- Attempt 1-2 hard problems
SUNDAY: Rest or light review
- Skim through week's concepts
- Organize notes
5.4 Interview Preparation Timeline
1 Month Before Interview
Complete all Blind 75 problems
Practice time management
Review all patterns
2 Weeks Before Interview
Focus on weak topics
Do 3-4 mock interviews
Practice explaining solutions
1 Week Before Interview
Light practice (2-3 problems/day)
Review common mistakes
Mental preparation
Day Before
Light review only
Rest well
Prepare logistics
5.5 Resources
Platforms
LeetCode: Primary practice platform
NeetCode: Curated lists and videos
AlgoExpert: Structured learning
HackerRank: Additional practice
Books
"Introduction to Algorithms" (CLRS)
"Cracking the Coding Interview"
"Elements of Programming Interviews"
YouTube Channels
NeetCode
Abdul Bari
William Fiset
Back To Back SWE
Phase 5 Checklist
Created study schedule
Completed 200 essential problems
Reviewed all patterns
Did mock interviews
Identified and addressed weak areas
Can explain solutions clearly
🎯 Final Summary
Phase
Focus
Duration
1
Foundation
2-3 weeks
2
Data Structures
4-6 weeks
3
Algorithm Paradigms
6-8 weeks
4
Advanced Topics
4-6 weeks
5
Practice & Review
Ongoing
Total Timeline: 4-6 months with consistent 3-4 hours daily practice
Remember: Mastery comes from understanding, not memorization. Focus on WHY solutions work, not just WHAT the solution is. Good luck on your DSA journey! 🚀