Coin Change II
Problem statement
Given distinct positive denominations coins and a nonnegative amount, return the number of unordered combinations that sum exactly to amount.
You may use each denomination any number of times. Different orders of the same multiset count once.
Function
countCoinChangeCombinations(coins: int[], amount: int) → longExamples
Example 1
coins = [1,2,5]amount = 5return = 4The combinations are 5; 2+2+1; 2+1+1+1; and five 1s.
Example 2
coins = [2]amount = 3return = 0No number of 2s sums to 3.
Constraints
1 <= coins.length <= 100.1 <= coins[i] <= 5000and denominations are distinct.0 <= amount <= 5000.- The answer fits in a signed 64-bit integer.