Lesson 75 of 86AdvancedPro Interactive Lesson

Minimum-Coin Change with Dynamic Programming

Try each usable denomination and extend the best solution for the remaining amount.

Core Intuition & How It Works

Minimum-coin change finds the fewest coins needed to make amount A by building dp[x] = 1 + min(dp[x - coin]) for every valid coin. Unlike greedy coin picking, DP finds the global optimum for any denomination set.

In the Byte Sized Algorithms interactive classroom, you can step forward and backward through this algorithm with your keyboard while watching the visual diagram, memory state, and highlighted pseudocode update together.

Time & Space Complexity

MetricComplexity
Time ComplexityO(amount × coins)
Space ComplexityO(amount)
Topic ChapterChapter 13: Dynamic Programming
Difficulty LevelAdvanced

Key Pattern to Recognize

Initialize dp[0] = 0 and all other entries to amount + 1 (sentinel Infinity), then check dp[amount] <= amount at the end.

Common Pitfalls & Edge Cases

Confusing minimum-coin count with number of combinations (where loop order—coins outer vs amount outer—determines whether order matters).

Real-World & Technical Interview Applications

Vending/change optimization, unbounded knapsack variants, and integer composition problems.

Unlock the full course

All 86 lessons across 15 chapters

View pricing

Delete account

This permanently deletes your account and ends any Pro access.