Given coin denominations and an amount, return the number of combinations that make up the amount. Coins can be used unlimited times, and the order of coins does not matter. This problem is central to understanding why loop order changes the DP meaning.
coins = denominations, amount = target
number of combinations to form the amount
Example 1:
Input:
amount = 5 coins = [1,2,5]
Output:
4
Explanation:
The combinations are 5, 2+2+1, 2+1+1+1, and 1+1+1+1+1.
Example 2:
Input:
amount = 3 coins = [2]
Output:
0
Explanation:
No combination can form 3 using only 2s.