Search⌘ K
AI Features

Minimum Coin Change

Explore dynamic programming approaches to find the minimum coins needed for a given amount using unlimited coin denominations. Understand and implement both naive recursive and optimized DP solutions to improve efficiency and reduce computing time. This lesson equips you to apply unbounded knapsack patterns effectively in coding interviews.

Statement

You’re given an integer total and a list of integers called coins. The integers inside the coins represent the coin denominations, and total is the total amount of money.

You have to return the minimum number of coins that can make up the total amount by using any combination of the available coins. If the amount can’t be made up, return -1. If the total amount is 0, return 0.

Note: You may assume that we have an infinite number of each kind of coin.

Let’s say, we have 33 coins (1, 2, 3) and want to make a total amount of 55. The minimum number of coins required to make this total is 22 coins, such that (2 + 3 = 5).

Constraints:

  • 11 \leq coins.length 12\leq 12

  • 11 \leq coins[i] 2311\leq 2^{31} -1 ...