Problem · Array
Minimum Coin Change
Learn this problemProblem 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) → intExamples
Example 1
coins = [1,2,5]amount = 11return = 311 = 5 + 5 + 1, so three coins are sufficient, and no two available coins sum to 11.