Given coin denominations and an amount, return the fewest number of coins needed to make that amount. Return -1 if it cannot be formed. This is the standard unbounded knapsack minimization problem.
coins = denominations, amount = target amount
minimum number of coins needed, or -1
Example 1:
Input:
coins = [1,2,5] amount = 11
Output:
3
Explanation:
11 = 5 + 5 + 1.
Example 2:
Input:
coins = [2] amount = 3
Output:
-1
Explanation:
Amount 3 cannot be formed using only 2s.