All lessons

Backtracking

10 min · C++ examples

Try choices, undo when they fail, and search all valid combinations.

C++ · Backtracking0/5 cleared

Enemy 1 of 5

Backtracking builds an answer piece by piece. Make a choice, recurse, then undo (backtrack) if the path doesn't work.

Generating all subsets is the hello-world of backtracking.

You
Cosmic-Ray Alien
Loading editor…
Sign up to fightThis one runs on our servers, so it needs a free account.

Stuck? Ask Rena

Your AI tutor that gives assistance.

Asking Rena in lessons is on Ultimate.