Deviopath › JavaScript

Minimum Coins

Hard · Dynamic Programming

Write a function minCoins that returns the fewest coins needed to make exactly amount, using coin values from coins (you have unlimited coins of each value).

If it is impossible, return -1. For amount 0 return 0. Note: always taking the biggest coin first does not always give the best answer.

Next: Unique Paths With Obstacles