Sliding Window
Solve fixed-window problems: maximum sum of k elements, moving averages, and O(n) updates as the window slides.
Solve a problem by having a function call itself on a smaller version of the same problem until it hits a base case.
Compute x raised to the power n without repeatedly multiplying one step at a time.
Generate every structurally unique binary search tree that stores values from 1 to n.
Check whether a binary tree satisfies the binary search tree property.
Find the sequence of moves that solves the Tower of Hanoi puzzle.
Flatten a linked list where nodes may have a child pointer into a single-level list.
The problem contains a smaller copy of itself. Reversing a list is reversing a shorter list and then attaching one item. Checking a tree is checking two smaller trees.
If you can describe the job in terms of the same job on something smaller, recursion fits.
Every recursive solution has exactly two pieces, and missing either one is the usual cause of failure.
The stopping case is the smallest version, where you already know the answer without asking again. The shrinking step is how you make the problem smaller before asking again, so you are guaranteed to reach the stopping case.
Factorial of a Number is the smallest possible example. It is only useful for seeing the two pieces clearly.
Reverse Linked List and Merge Two Sorted Lists next. Both are short, and both build their answer on the way back out of the recursion rather than on the way in, which is the first genuinely new idea here.
Pow(x, n) introduces halving. To raise a number to the twentieth power, raise it to the tenth and square it. Two calls collapse into one and a slow method becomes a fast one.
Validate Binary Search Tree teaches passing information downward. Each call needs to know the range its values are allowed to sit in, and that range comes from above.
Tower of Hanoi, Flatten a Multilevel Doubly Linked List and Unique Binary Search Trees II are the harder end. The last one builds every possible answer rather than one, which is a real step up.
A stopping case that can never be reached. Checking for exactly zero while the value drops by two at a time, so it steps straight past.
Calling the function and throwing away the result. A recursive call you do not return or store does nothing at all.
Redoing the same work over and over. If the same small problem keeps turning up, the fix is to remember previous answers, and that is where dynamic programming starts.
Solve fixed-window problems: maximum sum of k elements, moving averages, and O(n) updates as the window slides.
Scan a sorted array or string from both ends at once to find pairs, remove duplicates, or reverse data in O(n).
Cut a sorted range in half on every step to find a value or boundary in O(log n) instead of checking one by one.
Explore as far as possible down one path before backtracking, used to walk trees, graphs, and grids.
Explore level by level from a starting point, the go-to way to find the shortest path in an unweighted graph.
Break a problem into overlapping subproblems and reuse their answers to avoid recomputing the same work.