Match stopping and pruning to the question
Existence, one witness, counts, and enumeration need different return rules.
Understand the idea
An existence search may return after finding one answer. A counting search must add the results of disjoint branches; an enumeration must visit and output every answer. Reject a partial choice only after proving that none of its completions can succeed.
Trace a small example
For [0, 0] and target 0, all four subsets work. Returning 1 as soon as the current sum is zero would miss three. For signed [5, −4] and target 1, pruning when the current sum exceeds 1 would wrongly discard the successful pair.
Conditions and cost
The common sum > target prune requires that future choices cannot decrease the sum. Even with valid pruning, worst-case work can remain exponential. When returning a witness early, restore shared state or copy the answer before undoing it.
Is sum > target a valid prune when remaining values can be negative?
Turn the idea into code
Count subsets of [0, 1, 1] whose sum is 1.
Give me a hint
Choose one of the two 1 positions, then choose whether to include zero.
Show the explained solution
There are 2 × 2 = 4 subsets. Count at the leaf after all positions are decided, or use another equally justified counting rule.
Your notes
Mark complete when you can explain it yourself.