Backtracking algorithms are like problem-solving strategies that help explore different options to find the solution.
- work by trying out different paths and if one doesn’t work, then backtrack and try another until the right one is found
- useful for problems where you must generate all valid combinations, permutations or subsets under constraints
Backtracking is not for optimisation problems like DP , rather it is for when there are multiple solutions and you want all the solutions.
- Brute Force Approach
- for any given problem, you should try all possible solutions and pick up desired solutions
- build state space tree with DFS

General Outline of Backtracking Algorithm:
- choose an initial solution
- explore all possible extensions of the current solution
- if an extension leads to a solution, return that solution
- if an extension does not lead to a solution, backtrack to the previous solution and try a different extension
- repeat steps 2-4 until all possible solutions have been explored