Search across blog, articles, projects, courses, and community posts
You have an unlimited supply of each coin type. Find the fewest coins that add up to exactly the amount, or print -1 if it cannot be done.
Input:
n amount, the number of coin types and the target amount.n coin values.Output: the minimum number of coins, or -1.
1 <= n <= 12, 0 <= amount <= 10000, each coin is between 1 and 10000. An amount of 0 needs 0 coins.
3 11 1 2 5
3
1 3 2
-1