Problem · Array

Minimum Coin Change

Learn this problem
MediumMulticoreWareOA

Problem statement

Source context: The assessment report specified an unlimited supply of each denomination and asked for the minimum number of coins needed for a target. It did not provide an exact interface, examples, constraints, or unreachable-target convention.

Given positive coin denominations coins and a target amount, return the minimum number of coins whose values sum to exactly amount. Each denomination may be used any number of times.

Function

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

Examples

Example 1

coins = [1,2,5]amount = 11return = 3

11 = 5 + 5 + 1, so three coins are sufficient, and no two available coins sum to 11.

More MulticoreWare problems

drafts saved locally
public int coinChange(int[] coins, int amount) {
  // write your code here
}
coins[1,2,5]
amount11
expected3
checking account