Coin Change Ways
Return the number of combinations (order doesn't matter) of coins from coins (unlimited supply) that sum to amount.
Requirements
- Loop over coins in the outer loop so each combination is counted once.
Examples
EXAMPLE WALKTHROUGHfour ways
A guided view of the published example, not a trace of your code.
INPUT
[5,[1,2,5]]TASKcoin_change_ways()
EXPECTED OUTPUT
4Start with the input values shown in this example.
Example 1 of 3
Input: amount = 5, coins = [1,2,5]
Output: 4
Explanation: four ways
Input: amount = 3, coins = [2]
Output: 0
Explanation: impossible
Input: amount = 10, coins = [10]
Output: 1
Explanation: one coin
Hint 1
ways[a] += ways[a - coin] for every amount a >= coin, processing one coin at a time.