FastPrepMinimum Coins for an Amount
Problems/Minimum Coins for an Amount

Minimum Coins for an Amount

AMD logoAMD● MediumFULLTIMEONSITE INTERVIEW
QuestionFunctionExamplesConstraints

Problem statement

Source note: The report names Coin Change without specifying minimum coins or number of combinations. This exercise uses unlimited denominations and the minimum-coin objective, with explicit impossible and zero-amount results.

You are given positive integer coin denominations coins and a target amount. Each denomination may be used any number of times.

Return the minimum number of coins whose values sum exactly to amount. Return -1 if it cannot be formed. The minimum for amount zero is zero.

Function

minimumCoins(coins: int[], amount: int) → int

Examples

Example 1

coins = [1,3,4]amount = 6return = 2

Two coins of value 3 form 6. No single available coin forms 6.

Example 2

coins = [2]amount = 3return = -1

Every sum of coins of value 2 is even, so 3 is unreachable.

Constraints

  • 1 <= coins.length <= 20.
  • 1 <= coins[i] <= 2000.
  • 0 <= amount <= 2000.

More AMD problems

  • Insert After a Linked-List NodeONSITE INTERVIEW · Seen Oct 2026
  • LRU CacheONSITE INTERVIEW · Seen Oct 2026
  • Lowest Common Ancestor of a Binary TreePHONE SCREEN · Seen Oct 2026
All AMD interview questionsSee AMD hiring insights
Saved
public int minimumCoins(int[] coins, int amount) {
    // Write your code here.
}
Checking account…