Algorithms & data structures
75 interview-style coding challenges, with tests and explained solutions.
Arrays & Hashing8 problems
The starting point: a hash map or set turns an O(n) search into O(1). Almost every later topic leans on this.
Beginner guideTwo Pointers3 problems
Two indices moving toward each other over a (usually sorted) array or string, instead of a nested loop.
Beginner guideSliding Window4 problems
Two pointers that bound a contiguous range: grow and shrink a window, with a hash map counting what is inside.
Beginner guideStack1 problem
Last in, first out: the tool for nesting and matching problems, like brackets.
Beginner guideBinary Search2 problems
Throw away half the search space at every step for O(log n), even when the array is only partly sorted.
Beginner guideLinked List6 problems
Pointer manipulation: reversing, merging, and fast & slow pointers.
Beginner guideTrees11 problems
Recursion on trees: DFS, BFS, and what a binary search tree guarantees.
Beginner guide- 25Invert Binary TreeEasy
- 26Maximum Depth of Binary TreeEasy
- 27Same TreeEasy
- 28Subtree of Another TreeEasy
- 29Lowest Common Ancestor of a Binary Search TreeMedium
- 30Binary Tree Level Order TraversalMedium
- 31Validate Binary Search TreeMedium
- 32Kth Smallest Element in a BSTMedium
- 33Construct Binary Tree from Preorder and Inorder TraversalMedium
- 34Binary Tree Maximum Path SumHard
- 35Serialize and Deserialize Binary TreeHard
Heap / Priority Queue1 problem
O(log n) access to the smallest or largest item while data keeps arriving.
Beginner guideBacktracking2 problems
Exhaustive search with DFS: build a candidate step by step and undo the step when it leads nowhere.
Beginner guideAdvanced Graphs1 problem
Topological sort: an order that respects dependencies, when the graph itself is hidden in the input.
Beginner guide1-D Dynamic Programming10 problems
Break a problem into overlapping subproblems and keep their answers in one array.
Beginner guide2-D Dynamic Programming2 problems
The same idea when the state depends on two variables: a table instead of an array.
Beginner guideGreedy2 problems
The best choice now leads to the best result overall. The hard part is knowing when that holds.
Beginner guideMath & Geometry3 problems
In-place matrix manipulation: rotating, spiraling and marking.
Beginner guide