Problem
You have unlimited coins of each value in coins. Return the number of combinations that add up to exactly amount. Order does not matter: 1 + 2 and 2 + 1 are the same combination. If no combination works, return 0.
Example 1
- Input
- amount = 5, coins = [1, 2, 5]
- Output
- 4
- Why
- 5, 2+2+1, 2+1+1+1, 1+1+1+1+1
Example 2
- Input
- amount = 3, coins = [2]
- Output
- 0
Example 3
- Input
- amount = 10, coins = [10]
- Output
- 1
Constraints
1 <= coins.length <= 3001 <= coins[i] <= 5000All values in coins are unique.0 <= amount <= 5000The answer fits in a 32-bit signed integer.