Backtracking Patterns: Subsets, Permutations, N-Queens
A practical guide to backtracking: the recursion template, pruning, classic problems with code, and complexity analysis for subsets and permutations.
6 posts.
A practical guide to backtracking: the recursion template, pruning, classic problems with code, and complexity analysis for subsets and permutations.
Generate all subsets of an array in LeetCode 78 using backtracking and iterative bit-mask approaches. Includes complexity analysis and interview script.
Solve LeetCode 39 Combination Sum with a clean backtracking template. Pruning, duplicate avoidance, complexity discussion, and interview script.
Solve LeetCode 22 Generate Parentheses with counting-based backtracking. Clean invariant, walkthrough, complexity discussion, and interview tips.
Solve LeetCode 17 Letter Combinations of a Phone Number with backtracking. Mapping setup, recursive enumeration, complexity, and interview walkthrough.
Solve LeetCode 46 Permutations with backtracking and a used array. Compare swap-in-place vs used-array, walkthrough, complexity, and interview tips.