← Back to TypeScript
Backtracking
Choose, explore, unchoose — the skeleton that generates subsets, permutations and combinations without ever trusting a nested loop to do it.
Subsets by choose, explore, unchoose
advancedblankComplete the backtracking skeleton that enumerates every subset — the push, the recursive descent, and the undo.
Challenge: every permutation
advancedchallengeGenerate all orderings of distinct values with backtracking — a used set, a path, and a swap of perspective.
Challenge: combinations that sum to a target
advancedchallengeFind every combination of numbers that adds to a target, reusing each number as often as needed — backtracking where the loop start carries the no-duplicates rule.
Review: the generator that never unchooses
advancedreviewA subset generator is right for inputs of one element and quietly produces garbage and gaps from two onward. Find the missing undo.