Learning order

1. Recursion

Premium

Take a deep dive into one of the most intuitive programming paradigm

Show Index

2. Backtracking

Premium

Learn about the ultimate recursive brute force technique

Show Index

3. Sorting

Premium

Learn all about algorithms to sort data blazingly fast

Show Index

4. Searching

Premium

Learn about the algorithms that speed up your searches exponentially

Show Index

5. Dynamic Programming

Premium

Learn the most powerful optimization for recursive problems

(Early Access)

Show Index

6. Bit Manipulation

Premium

Learn about the fastest ways to manipulate data

(Early Access)

Show Index

What you will learn

How a state space tree models every backtracking solution

The three conditions a problem must satisfy to admit a backtracking solution

Unconditional enumeration for problems where each step's choices are independent

Conditional enumeration where a control variable filters the next step's choices

Backtracking search for problems that need one valid configuration, not all of them

Pruning rules that kill defying subtrees before they ever reach a leaf

Why this course

Most engineers see backtracking and think "just try every combination". That intuition holds for toy problems and collapses the moment an interviewer asks for every valid set of parentheses, every well-formed IP address, or any board that solves Sudoku. The state space explodes, the brute force you had in mind never finishes, and you cannot say why your recursion is doing the work it is doing.

This course teaches backtracking as three concrete templates you can recognise on sight. Unconditional enumeration, conditional enumeration, and search. You build each template on a state space tree, learn the pruning rules that make the worst-case O(k^N) tree tractable in practice, and finish on N-Queens, Sudoku, and word search on a grid.

Requirements

The course assumes comfort with recursion, but no prior exposure to backtracking is needed.

  • Ability to write and trace a recursive function in at least one language.
  • A working mental model of the call stack as it grows and unwinds.
  • Familiarity with Big-O notation including exponential bounds like O(k^N).

Overview

Backtracking is the algorithmic technique behind every problem that asks you to enumerate all valid configurations or find one that satisfies a set of constraints. Listing every subset of a set, building every well-formed pair of parentheses, generating valid IP addresses from a digit string, placing N queens on a board so none attack each other, and walking a rat through a maze are all the same idea wearing different costumes. Build a solution incrementally, validate at each step, and unwind the choice when the path leads to a dead end.

Abstract representation of backtracking

This course covers both halves of the topic. The recursion mechanics that make backtracking work, and the three problem-solving patterns that cover almost every backtracking question you will see.

Fundamentals

The course opens with the three conditions a problem must satisfy for backtracking to apply. A finite set of possible outcomes. A validator that decides whether a configuration is a solution. A recursive structure that builds a state space tree, the picture every later pattern relies on. You learn to draw the state space tree for a four-digit phone unlock problem first, because once that tree is on paper, every later pattern is just a different shape of the same tree.

From there the introduction covers how recursion implements the tree. Each recursive call corresponds to one node. The call stack remembers the path from root to the current state, so unwinding the stack literally is backtracking. You see how to make a choice, validate, recurse, and revert the choice on the way back up. By the end of the introduction you can write the choose-recurse-revert template from memory and apply it to the toy unlock problem the course uses to motivate the idea.

The introduction closes with pruning. A backtracking algorithm without pruning is just exhaustive enumeration. The course shows where to plant the bounding check so that defying states never spawn subtrees, why this changes the practical running time even though the worst case stays at O(k^N), and how a well-ordered choice list can find a solution far faster than a poorly-ordered one.

Problem solving

After the fundamentals, the rest of the course is patterns. Almost every backtracking problem you will see in an interview reduces to one of three templates, and naming the right one is most of the work.

The 3 backtracking patterns you'll master
Unconditional enumeration
A backtracking template that makes k independent choices at each of n recursion steps and visits every node of the state space tree, running in O(k^N) time. Unique Subsets, Case Transformations, Number Sequence, Phone Combinations.
Conditional enumeration
A backtracking template that tracks a control variable so each step's available choices depend on the path so far. The worst case stays at O(k^N) but pruning trims it heavily in practice. Generate Parentheses, Target Sum Combinations, Generate IP Addresses, String Permutations.
Backtracking search
A backtracking template that halts as soon as one solution state is found, giving O(1) best case and O(k^N) worst case depending on choice ordering. Rat in a Maze, Word Quest, Solve N-Queens, Solve Sudoku.

Each pattern is taught in three layers. An Understanding lesson walks the template on a problem where the structure is obvious. An Identifying lesson teaches the signals that tell you a new problem fits the template, the same triggers an experienced engineer reads from a problem statement. Then four problems drill the template at increasing difficulty. The course ends on Sudoku, the canonical demonstration that a well-pruned backtracking search solves a problem with billions of candidate boards in milliseconds.

How this course is different

Most backtracking material online treats the topic as a parade of famous puzzles. This course refuses to teach the puzzles without first teaching the structure that makes them work.

Most DSA resources
This course
Skip the state space tree and jump straight to "here is how N-Queens works".
Opens with the state space tree, so every problem maps onto a picture you can draw before you code.
Teach unconditional and conditional enumeration as if they were the same template.
Treats unconditional, conditional, and search as three distinct templates with different signals and different bounds.
Confuse pruning with the recursion itself, so the two ideas never separate.
Separates recursion mechanics from pruning logic so you can apply each independently.
Show search and enumeration as different topics instead of the same template with an early exit.
Teaches search as a one-line modification of enumeration, not a different algorithm.
Stop at Sudoku without showing you how to spot the pattern in unfamiliar problems.
Devotes an Identifying lesson per pattern so you can spot the template on problems you have never seen.

Who this course is for

The course suits anyone who needs to actually understand backtracking instead of memorising five canonical puzzles.

  • New programmers who can write a recursive function but cannot explain what the call stack is doing on the way back up.
  • Self-taught and bootcamp graduates who solved N-Queens once with a tutorial open and want to solve the next backtracking problem cold.
  • Working developers who can write a solver for one problem but cannot recognise when a new problem calls for the same approach.
  • Engineers preparing for FAANG and Big Tech interviews where combinatorial generation and constraint search appear in nearly every problem-solving round.
  • Returning engineers who learned recursion years ago and want a clean refresher built around the state space tree.
  • Anyone who has noticed they freeze when a problem says "find all" or "find any" valid configuration, and wants to fix that.

Continue your DSA journey

Backtracking sits at a junction in the curriculum. After this course, several adjacent topics either build on the recursion mechanics you just learned or solve the same problems from a different angle.

  • Stack: The call stack is what makes recursive backtracking work. Once you can drive an explicit stack, you can convert any backtracking solution into an iterative one, which is occasionally what an interviewer wants when recursion depth would blow the implicit stack.
  • Binary tree: Recursive tree traversal and backtracking share the same descend-then-return structure. The path-finding habits you build here transfer cleanly to root-to-leaf and lowest-common-ancestor problems where you need to remember the current path while recursing.
  • Graph: Depth-first search on a graph is backtracking applied to an explicit graph instead of an implicit state space tree. The same choose, recurse, revert template solves cycle detection, connected components, and two-colouring once you adapt it to graph nodes.
  • Recursion: Backtracking is recursion with a make-and-revert step wrapped around every recursive call. If the recursion course's mental model of the call stack is shaky, the backtracking templates here will feel like magic instead of mechanics. Worth doing first if your recursion is rusty.
  • Dynamic programming: DP and backtracking are siblings. Both walk a state space. Backtracking re-explores overlapping subproblems while DP memoises them. Knowing both lets you pick the right tool when a problem admits either solution.

Frequently asked questions

Code examples are in Python because the recursion reads cleanly, but every concept (state space tree, choose-validate-revert, pruning) is language-agnostic. Translating a Python backtracking solution into Java, C++, or JavaScript is mechanical.
Backtracking is recursion with extra structure. If you can write a factorial or a Fibonacci function and trace what the call stack does on the way down and back up, you have what you need. If recursion still feels mysterious, work through the recursion course first and come back.
There are 9 lessons across the introduction and the three patterns, plus 12 problems. Most learners finish the lessons in 6 to 9 hours and need another 12 to 18 hours to work through the problems, depending on prior recursion experience.
Backtracking appears in interview rounds whenever a problem asks for "all valid X", "any valid X", or a configuration that satisfies a constraint set. The three templates here cover almost every interview backtracking question, including the popular N-Queens, Sudoku, balanced parentheses, IP-address, and permutation problems.
LeetCode lists problems individually with no grouping. This course teaches the three templates first, then drills problems within each template so you build pattern recognition. After the Identifying lesson for a template, you can spot a new problem that fits it on first read instead of guessing.
Worst-case backtracking is O(k^N) where k is the branching factor and N is the recursion depth. Pruning shrinks the constant, not the exponent. If your recursion keeps solving the same subproblem along different paths, switch to dynamic programming with memoisation. If the constraints have algebraic structure, constraint propagation collapses the tree further before you ever enter the recursion.
They are the same recursive walk applied to two different objects. DFS traverses an explicit graph or tree given as input. Backtracking traverses an implicit state space tree that the recursion itself constructs as it makes choices. The revert step exists in backtracking because state mutates as you descend, so it has to be undone on the way back. DFS on an immutable graph never needs that step.
Yes. Once you finish all lessons and the problem set, codeintuition issues a shareable certificate you can post to LinkedIn or attach to a job application.