All topics
4 patterns · 18 problems

Recursion

Solve a problem in terms of smaller versions of itself: divide & conquer, backtracking, and recursive search.

01Pattern

Basic Recursive Functions

Call yourself on a smaller problem until you hit bottom.

When to reach for it

  • Implement basic recursive functions that solve a problem by dividing it into smaller instances of the same problem until a base case is reached.

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.

Easy

N-th Tribonacci Number

LeetCode
Loading animation…

How to solve it

Animation: Basic Recursive Functions technique

Define 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 solution

Practice · 5 problems

Select any problem to watch the technique run. marks a problem with its own bespoke animation.

02Pattern

Divide & Conquer

Split, solve each half, then merge the answers.

This patternO(n log n)naïve O(n²)

When to reach for it

  • Break down a problem into smaller subproblems of the same type, solve each subproblem recursively, and combine their solutions to solve the original problem.

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.

Easy Bespoke animation

Binary Search

LeetCode
Loading animation…

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 solution

Practice · 4 problems

Select any problem to watch the technique run. marks a problem with its own bespoke animation.

03Pattern

Backtracking

Try a choice, recurse, undo it, try the next.

When to reach for it

  • Explore all potential solutions to a problem by trying out different choices and backtracking when a dead-end is reached, undoing choices and trying alternative paths.

Spot it in the prompt

Problems where you need to find all permutations, combinations, or subsets of elements while satisfying specific constraints.

Medium

Generate Parentheses

LeetCode
Loading animation…

How to solve it

Animation: Backtracking technique

Recursively add '(' while open < n and ')' while close < open, recording each complete valid string.

Open full solution

Practice · 5 problems

Select any problem to watch the technique run. marks a problem with its own bespoke animation.

You've got the patterns

Patterns get you through the screen. Shipping gets you hired.

FDE 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

August 15 · 0d left
Enroll Now