stamps, with an unlimited supply of each value. You need to put stamps worth exactly total on an envelope.
Count how many different sets of stamps do that. The order of sticking them on does not matter: two sets differ only in how many stamps of each value they use. If the amount cannot be made, return 0.
The answer is guaranteed to fit in a signed 32-bit integer.total=6, stamps=[1, 3, 4] → 4
The sets 1+1+1+1+1+1, 3+1+1+1, 3+3 and 4+1+1 work, 4 in total.
total=7, stamps=[2, 4] → 0
Even values can never add up to an odd total.
total=0, stamps=[5] → 1
There is exactly one way to pay zero: use no stamps.
total=6, stamps=[1, 3, 4]
4
Run checks the first 3 tests in your browser. Submit checks all 74 tests on the server, hidden ones included.