Coin change
Finding the fewest coins, each type usable many times, that add up exactly to an amount, or counting how many ways it can be made.
Example
With coins of 1, 2 and 5, the amount 11 is made with 3 coins: 5 + 5 + 1.
Test yourself: Coin change
Unbounded knapsack and coins
With coins of 1, 2 and 5, the amount 11 is made with at least ___ coins.
5 + 5 + 1 = 11: 3 coins. With only 1-coins it would be 11.
Unbounded knapsack and coins
To mark an impossible amount, instead of infinity amt + ___ is used.
With amt = 11, 12 is used: with 1-coins, you never need more than 11, so 12 is never a real answer.
Unbounded knapsack and coins
With coins of 1, 2 and 5, the amount 5 can be made in ___ ways.
{5}, {2, 2, 1}, {2, 1, 1, 1} and {1, 1, 1, 1, 1}: 4 combinations.
0/3
â–¶ Play