Subset sum
The problem of finding the groups of numbers in a list that add up exactly to a target. In a subset the order does not matter.
Example
With [3, 4, 5] and target 9, repeats allowed: {3, 3, 3} and {4, 5}. {5, 4} is the same as {4, 5}.
Test yourself: Subset sum
Subset sum
In a subset the ___ does not matter.
{4, 5} and {5, 4} both add up to 9, and they are the same subset.
Subset sum
Adapting permutations, with [3, 4, 5] and target 9, [4, 5] and [5, ___] show up as repeats.
Choosing 4 and then 5 is a different branch from choosing 5 and then 4, but both add up to 9 with the same numbers.
Subset sum
With the array sorted, if a choice goes past the target, the for loop is ___.
With [3, 4, 5] and remaining target 3, the 4 already goes past: the 5 would too, so it is not tried.
0/3
â–¶ Play