Backtracking

I realized I ain’t learn shit in CPSC320.
Backtracking are perfect for questions like

• Permutation
• Combination
• Subset

It’s easier to treat backtracking problems as a tree, and typically, answers are where leaf nodes are located. While trying to solve those problems, we are traversing the tree, and backtracking happens when we undo our last operation to path to prepare for the next iteration.

Just remember the template to solve backtracking problems: