Solve a problem in terms of smaller versions of itself: divide & conquer, backtracking, and recursive search.
Call yourself on a smaller problem until you hit bottom.
When to reach for it
Spot it in the prompt
Problems where the solution can be naturally expressed in terms of smaller instances of the same problem, such as factorial calculation, Fibonacci sequence generation, or exponentiation.
How to solve it
Animation: Basic Recursive Functions techniqueDefine T(n) = T(n-1) + T(n-2) + T(n-3) recursively from the base cases, memoizing so shared subproblems aren't recomputed.
Open full solutionSplit, solve each half, then merge the answers.
O(n log n)naïve O(n²)When to reach for it
Spot it in the prompt
Tasks where the solution to a larger problem can be obtained by recursively combining solutions to smaller instances of the same problem, such as binary search or finding maximum or minimum elements in an array.
How to solve it
Recurse on half the sorted array by comparing the middle element to the target, discarding the impossible half each call.
Open full solutionTry a choice, recurse, undo it, try the next.
When to reach for it
Spot it in the prompt
Problems where you need to find all permutations, combinations, or subsets of elements while satisfying specific constraints.
How to solve it
Animation: Backtracking techniqueRecursively add '(' while open < n and ')' while close < open, recording each complete valid string.
Open full solutionExplore branches recursively until you find the target.
When to reach for it
Spot it in the prompt
Problems involving searching for specific elements or solutions in a structured or unstructured search space. Tasks requiring finding paths in mazes, solving Sudoku puzzles, or searching for elements in a tree or graph.
How to solve it
Scan the grid and flood-fill via DFS from each unvisited land cell, sinking connected land and counting one island per launch.
Open full solutionFDE Coach is a cohort-based program in frontend, backend, AWS, and AI where you build real products and get referred to 200+ hiring partners. The free live workshop is the fastest way to see how we teach.
750+ engineers trained · frontend, backend, AWS & AI