Module 9 · Backtracking · Backtracking: Inclusion–Exclusion

Combination sum II

Subsets II with a running score. A call buildSubSets(nextUnique, currentScore) adds the list to subSets when currentScore equals target, and returns once the box is used up or the score has reached the target. Otherwise it takes 1, 2, … copies of the next value (one branch each), puts them back, and goes on without it. In the tree a box shows the list a call starts from with a jar filled by currentScore / target (✕ once it is past the target), and a branch shows what was added or skip.