A curated list of 40 must-practice coding problems commonly asked in top tech interviews, organized by problem-solving patterns.
- Sliding Window
- Two Pointers
- Fast & Slow Pointers
- Stack
- Binary Search
- DFS/BFS
- Topological Sort
- Heap / Priority Queue
- Backtracking
- Dynamic Programming
- Tree DFS/BFS
- Prefix Sum / Tricks
- Sorting & Greedy
- Design
- Trie, Union-Find, Matrix Traversal
-
Longest Substring Without Repeating Characters
DS:
String, HashSet |Time:
O(n)
Note:
Use HashMap/Set to track characters -
Minimum Window Substring
DS:
String, HashMap |Time:
O(n)
Note:
Two hash maps – one for required, one for window -
Sliding Window Maximum
DS:
Deque |Time:
O(n)
Note:
Maintain decreasing deque
-
Container With Most Water
DS:
Array |Time:
O(n)
Note:
Shrink window from sides, track max area -
Trapping Rain Water
DS:
Array |Time:
O(n)
Note:
Use leftMax and rightMax pointers
-
Two Sum
DS:
Array, HashMap |Time:
O(n)
Note:
Complement pattern -
Product of Array Except Self
DS:
Array |Time:
O(n)
Note:
Avoid using division
-
Detect Cycle in Linked List
DS:
Linked List |Time:
O(n)
Note:
Floyd’s Cycle Detection -
Palindrome Linked List
DS:
Linked List |Time:
O(n)
Note:
Reverse second half
-
Valid Parentheses
DS:
String, Stack |Time:
O(n)
Note:
Match opening and closing -
Min Stack
DS:
Stack |Time:
O(1) per operation
Note:
Track min with auxiliary stack
-
Search in Rotated Sorted Array
DS:
Array |Time:
O(log n)
Note:
Handle pivot logic -
Find Minimum in Rotated Sorted Array
DS:
Array |Time:
O(log n)
Note:
Binary search on rotated array -
Median of Two Sorted Arrays
DS:
Array |Time:
O(log(min(n,m)))
Note:
Partition logic in binary search
-
Number of Islands
DS:
Grid |Time:
O(m*n)
Note:
Mark visited on grid -
Clone Graph
DS:
Graph, HashMap |Time:
O(V+E)
Note:
Use visited map -
Word Ladder
DS:
Graph |Time:
O(N * L^2)
Note:
Transform word by word -
Binary Tree Level Order Traversal
DS:
Tree, Queue |Time:
O(n)
Note:
Queue for level tracking
- Course Schedule
DS:
Graph |Time:
O(V + E)
Note:
Kahn’s algorithm or DFS cycle detection
-
Kth Largest Element in Array
DS:
Heap |Time:
O(n log k)
Note:
Min Heap of size k -
Top K Frequent Elements
DS:
Heap, HashMap |Time:
O(n log k)
Note:
Frequency map + Heap -
Merge K Sorted Lists
DS:
Linked List, Heap |Time:
O(N log k)
Note:
Min Heap of list nodes
-
Subsets
DS:
Array |Time:
O(2^n)
Note:
DFS include/exclude -
Permutations
DS:
Array |Time:
O(n!)
Note:
Track used elements -
Combination Sum
DS:
Array |Time:
O(2^n)
Note:
Include current or skip
-
Maximum Subarray
DS:
Array |Time:
O(n)
Note:
Kadane’s Algorithm -
Coin Change
DS:
Array |Time:
O(amount * coins)
Note:
Bottom-up DP -
Decode Ways
DS:
String |Time:
O(n)
Note:
dp[i] = dp[i-1] + dp[i-2]
-
Maximum Depth of Binary Tree
DS:
Tree |Time:
O(n) -
Lowest Common Ancestor
DS:
Tree |Time:
O(n) -
Serialize and Deserialize Binary Tree
DS:
Tree |Time:
O(n) -
Diameter of Binary Tree
DS:
Tree |Time:
O(n)
-
Merge Intervals
Pattern:
Sorting |Time:
O(n log n) -
Add Two Numbers
Pattern:
Linked List |Time:
O(max(m,n)) -
LRU Cache
Pattern:
Design |Time:
O(1)
Note:
Use HashMap + Doubly Linked List -
Jump Game
Pattern:
Greedy |Time:
O(n) -
Redundant Connection
Pattern:
Union-Find |Time:
O(n) -
Implement Trie (Prefix Tree)
Pattern:
Trie |Time:
O(n) -
Daily Temperatures
Pattern:
Monotonic Stack |Time:
O(n) -
Spiral Matrix
Pattern:
Matrix Traversal |Time:
O(m*n)