Write a function to find the minimum number of coins needed to make a given amount of
Fantastic news! We've Found the answer you've been seeking!
Question:
Write a function to find the minimum number of coins needed to make a given amount of money. The function should take in a list of available coin denominations and the amount of money, and return the minimum number of coins needed. The function should first sort the coin denominations in decreasing order and then use dynamic programming to solve the problem.
Example:
Input:
denominations = [1, 5, 10, 25]
amount = 41
Output: 6
Explanation: The minimum number of coins needed to make 41 cents is 6, using one 25-cent coin, one 10-cent coin, and one 5-cent coin, and one 1-cent coin.
Related Book For
Data Structures and Algorithm Analysis in Java
ISBN: 978-0132576277
3rd edition
Authors: Mark A. Weiss
Posted Date: