Why it matters
Coin change is classic DP. Understanding shapes unbounded knapsack.
Advertisement
The architecture
dp[a] = min coins for amount a.
Or dp[a] = number of ways.
Iterate over amounts + coins.
Advertisement
How it works end to end
Min coins: dp[a] = min(dp[a], dp[a-c] + 1).
Ways: dp[a] += dp[a-c] with coin outer loop.
Unbounded (repeats OK).