Level 5

Backtracking

Backtracking is the method of building the solution one piece at a time recursively and incrementally. The method keeps removing all those bits that do not contribute to the solution.

One such real-life example is a maze. At every dead end, you trace back your steps and set out for another path- thus setting a perfect example for backtracking. Similarly, Sudoku works on the same principle.

That’s what backtracking is, retracing back the steps and discarding the choice that doesn't add on to build the correct solution.

Backtracking

Important Tutorials

1. Recursion Basics Using Factorial
View Tutorial
2. Complexity Analysis Of Recursive Programs
View Tutorial
3. Why Recursion Is Not Always Good
View Tutorial
4. Time Complexity Analysis Of Recursion
View Tutorial
5. Space Complexity Analysis Of Recursion
View Tutorial
6. Backtracking
View Tutorial
7. Backtracking Pseudocode
View Tutorial

Backtracking Problems

Subsets
Problem Score Companies Time Status
Subset 250 57:07
Combinations 300 41:45
Combination Sum 300 55:44
Combination Sum II 300 37:10
Subsets II 300 36:05
Bruteforce builder
Problem Score Companies Time Status
Letter Phone 250 49:30
Palindrome Partitioning 300 60:34
Generate all Parentheses II 350
47:31
Pruned builder
Problem Score Companies Time Status
Palindrome Partitioning 300 60:34
Generate all Parentheses II 350
47:31
NQueens 550 66:46
Sudoku 700 57:07
Permutations
Problem Score Companies Time Status
Permutations 350 36:40
Maths and backtracking
Problem Score Companies Time Status
Gray Code 350
52:14
Kth Permutation Sequence 350 67:55
Game solving
Problem Score Companies Time Status
NQueens 550 66:46
Sudoku 700 57:07