Loading...
Loading...
Loading...
A shop has n coupons with integer values. Count the groups of coupons (subsets, chosen by position) whose values add up to exactly T. The empty group counts when T is 0.
Example 1
Input
4 5 1 2 3 4
Output
2
{1,4} and {2,3}.
Example 2
Input
3 0 1 -1 0
Output
4
Try the problem first. Open one hint at a time.
For each coupon you either take it or leave it.
A recursive function with an index and the remaining target tries both choices.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor