Coin Change — Filling the DP Array, One Coin at a Time

Min coins: dp[v] = min(dp[v], dp[v-c]+1).   Count ways: dp[v] += dp[v-c] (coin-outer = combinations). Watch each coin relax the table left to right.

step 0

Coins (outer loop) & recurrence

dp[ ] array

dp[v] being updated dp[v - c] (the source) active coin

What this shows

Combinations vs permutations: this demo uses the coin-outer loop, so the count variant counts combinations (multisets). Each coin is fully processed before the next, so 1+2 and 2+1 are the same. Swapping to amount-outer would count permutations instead.

Forward sweep = unbounded: because v runs from c upward, dp[v-c] is already updated in this pass, so the coin can be reused any number of times. A backward sweep would model the 0/1 (use-once) case.

Min vs count: min uses min(dp[v], dp[v-c]+1) (∞ marks unreachable amounts, shown in red); count uses dp[v] += dp[v-c] with dp[0]=1.

Final answer readout

Run to completion to see dp[V].
Press Step to begin. We process coins in the OUTER loop (so the count variant counts combinations) and sweep amounts forward (so coins are reusable — the unbounded case).
Self-contained visualization. Forward sweep => unbounded reuse (each coin usable any number of times). Min uses min(dp[v], dp[v-c]+1) with INF for unreachable amounts; count uses dp[v] += dp[v-c] with dp[0]=1. Switch the loops to amount-outer and the count variant would instead count permutations. See junior.md and professional.md.