Coin Change DP Visualizer

Find the minimum number of reusable coins needed for a target amount, with each DP update shown step by step.

Coins
3
Target
6
Min coins
2
Coin
-

Coin input

Step controls

Start with dp[0] = 0 and every other amount unreachable.

Amount table

Current amount: 0, candidate: inf

Current From amount
0
1
2
3
4
5
6
0
inf
inf
inf
inf
inf
inf

DP output

coin = -
amount = 0
from_amount = -
candidate = inf
min_coins = 2
selected = [3, 3]

Chosen coins

1: 32: 3

Coin set

134

What is a Coin Change Visualizer?

A coin change visualizer shows how dynamic programming solves a target amount from reusable coin denominations. This page focuses on the minimum-coins version of the problem.

Enter coin values and a target amount, then inspect each DP update, the amount that feeds the candidate value, and one reconstructed optimal coin set.

For the full algorithm set, browse the Data Structure Visualizers hub.

How to use this coin change visualizer

  • Enter coin denominations such as 1, 3, 4.
  • Enter the target amount.
  • Click Run Coin Change to compute the minimum number of coins.
  • Step forward to inspect each amount update for each coin.
  • Read the selected coins in the output panel.

Coin change and dynamic programming

For the minimum coin problem, dp[amount] stores the fewest coins needed for that amount. When coin c is available, the candidate value is dp[amount - c] + 1.

For related DP table problems, compare this page with the Longest Increasing Subsequence Visualizer, Longest Common Subsequence Visualizer, Edit Distance Visualizer, and Knapsack DP Visualizer.

Frequently Asked Questions

Which coin change variant does this tool show?
This visualizer shows the unbounded minimum-coins variant, where each denomination can be reused any number of times.
What does dp[amount] mean?
dp[amount] is the fewest coins currently known to make that amount. If it is marked `inf`, that amount is not reachable yet.
Can coin change have no solution?
Yes. If the target cannot be formed from the given denominations, the final target cell stays unreachable.
What is the time complexity of this coin change DP?
The unbounded minimum-coins DP runs in O(number of coins times target amount).

Related tools