Problem-solving patterns
Most DSA problems are variations on a small set of techniques. Learn the technique once, then recognise it in new problems.
Arrays and strings
Techniques for getting through a list or a piece of text in a single pass.
Hashing
Remember what you have seen in a map or set, so each later check is a lookup instead of a loop.
4 practice problems
Two Pointers
Move two indexes through a sequence, usually from both ends towards the middle, to avoid a nested loop.
5 practice problems
Sliding Window
Keep a running result for a contiguous range and update it as the range moves, instead of recalculating from scratch.
5 practice problems
Prefix Sums
Store running totals once, then get the sum of any range with a single subtraction.
3 practice problems
Searching
Finding a value or a boundary in sorted data without looking at every item.
Binary Search
Halve the search range at every step by comparing against the middle of sorted data.
4 practice problems
Binary Search on the Answer
Guess the answer, test the guess with a quick yes-or-no check, and halve the range of possible answers.
3 practice problems
Peak Finding
Find the top of data that rises then falls by asking which slope the middle item is on.
3 practice problems
Matrix Search
Use the order in a sorted grid to throw away a whole row or column with each comparison.
3 practice problems
Rotated Sorted Arrays
A rotated sorted array has at most one drop, so one comparison with the right end still lets you throw away half of it.
3 practice problems
Stacks and linked lists
Problems where the order things arrive in, or the links between them, do the work.
Stack and Monotonic Stack
Keep unfinished items on a stack and resolve the most recent one first, in O(n).
3 practice problems
Linked List Pointer Techniques
Solve linked list problems in place with fast and slow pointers, link reversal and a dummy head.
3 practice problems