| Topic | Difficulty | Companies |
|---|---|---|
| Dynamic Programming | MEDIUM | Microsoft |
Given a set of coins arr[] and amount, Write a program to find the minimum number of coins to make the change of given amount.
Problem Note
m number of different coin types available arr[] = [C1, C2, … Cm]. Here, arr is an array of integers representing available denominations.amount cannot be made up by any combination of the coins, return -1.Example 1
Input: arr[] = [1, 2, 3, 4] , amount = 11
Output: 3
Explanation: We can use two coins of 4 cents and one coin of 3 cents i.e. 11 = 4 + 4 + 3
Example 2
Input: arr[] = [3, 4] , amount = 5
Output: -1
Explanation: Amount 5 cannot be made up by any combination of the coins.