AlgoScope

Combination Sum

AlgorithmintermediateBacktracking

Choose candidates with reuse, in non-decreasing order, until the sum hits the target; prune the moment a pick would overshoot.

Decision · step 2 of 29Enumeration: Sums to 7 with repeats allowed
20316273i

7 still needed, a[0] = 2 fits: pick it, {2}, 5 to go. Candidates from index 0 onward stay available, so 2 may repeat.

Open in the player →or start at step 2

What you will see

Branches die the moment the running sum overshoots.

How enumeration works →

Cost

BestO(n^(t / min))
AverageO(n^(t / min))
WorstO(n^(t / min))
SpaceO(t / min)

t is the targetmin the smallest candidate.

How you work with it here

play it through, step one change at a time, scrub to any step, run it on your own input, predict what happens next.

Screen readers: Each node of the decision tree announces the choice made and whether it led to success, failure or further choices.

Reduced motion: Tree nodes appear and grey out in place; no travelling focus.

Before this

Taught by the same lesson

Enumeration covers these too, in the same run.