DSA · Reimagined
Recursion & DP medium time O(amount × coins) space O(amount)

DP — Coin Change

Solve every smaller amount first. For an amount, try each coin: using it costs one coin plus the best answer for the remainder. Because smaller amounts are already solved, each entry is one quick minimum.

coins available
1
0
3
1
4
2
dp[a] = fewest coins for amount a
0
1
2
3
4
5
6

Find the fewest coins making every amount up to 6.

1 / 21
A fixed scene — scrub through it, or open the code.

Practice

Machine twin: /dsa-viz-v2/coin-change.json — the full deterministic run as structured data.