Minimum Coins for Toll

ARRAY
DYNAMIC PROGRAMMING

Problem

Given an array denominations representing different coin denominations and an integer tollAmount representing the total amount needed, compute the minimum number of coins required to make up that amount. If it is not possible to make up the amount with the given coin denominations, return -1.

Examples

findMinCoins([2, 5, 10], 7) // returns 2 // Why? 2 + 5 = 7 findMinCoins([1, 3, 4], 6) // returns 2 findMinCoins([3], 8) // returns -1
Loading...