- Tutorials
- DSA Tutorial
- Backtracking
Backtracking
2 lessonsAbout 12 minutesIntermediate
This part of the DSA Tutorial runs from Backtracking Explained through to Classic Backtracking Problems. There are 2 lessons here, and working through them takes about 12 minutes at a steady pace.
It follows on from Recursion, so finish that first if you have not already — the examples below assume you are comfortable with it.
Each lesson below says what it covers before you open it. Read them in order the first time; afterwards this page works as a index you can jump back into when you need to check one thing.
- 1Backtracking ExplainedBacktracking builds a solution one choice at a time and undoes choices that fail. Learn the choose-explore-unchoose template in JavaScript with permutations and subsets.
- 2Classic Backtracking ProblemsN-Queens, word search and sudoku — the backtracking problems asked most often, each solved in JavaScript with the pruning that makes them tractable.
