Coin Change II
Count distinct multisets of coins summing to amount, with unlimited copies of each denomination. Different orders of the same coins count once; amount zero has one empty combination.
Example 1
amount = 6
coins = [1,3,4]4Explanation
The multisets are six 1s, 3 plus three 1s, two 3s, and 4 plus two 1s.
Example 2
amount = 7
coins = [2,4]0Explanation
Even-valued coins cannot total odd amount 7.
Example 3
amount = 0
coins = [3]1Explanation
Zero has one combination: choose no coins.
Constraints
- 0 <= amount <= 5000
- 1 <= number of distinct positive coins <= 300
- The answer fits a signed 32-bit integer
Function contract
changeArguments: json, jsonSolutionRuns on your device
Loading draft…
Run: 3 examples; Submit: 35 cases, on your device.
6[1,3,4]