Basic example
Input
amount = 5, coins = [1, 2, 5]
Output
4
Combinations: {1+1+1+1+1}, {1+1+1+2}, {1+2+2}, {5}
Full lesson preview
Compute the number of distinct combinations to form a target amount using unlimited coins.
Problem statement
Task
Examples
Input
amount = 5, coins = [1, 2, 5]
Output
4
Combinations: {1+1+1+1+1}, {1+1+1+2}, {1+2+2}, {5}
Input format
Output format
Constraints
Samples
Input
count_ways(0, [1,2])
Output
1
There is exactly one way to make amount 0: choose no coins.