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
Packet Wolf

Loading editor...

Ln 1, Col 1Spaces: 4
Sign up to fightTarget output: 8