Given a total amount of N and unlimited number of coins worth 1, 10 and 25 currency coins. Find out the minimum number of coins you need to use to pay exactly amount N.
Input : N = 14 Output : 5 You will use one coing of value 10 and four coins of value 1. Input : N = 88 Output : 7
There are three different cases:
- If value of N < 10, then coins that have value 1 can only be used for payment.
- When N > 9 and < 25, then coins that have value 1 and 10 will be used for payment. Here, to minimize the number of coins used, coins with value 10 will be preferred mostly.
- When N > 24. Then all coins of value 1, 10 and 25 will be used for payment. To minimize the number of coins, the primary aim will be to use coin with value 25 first as much as possible then coin with value 10 and then with value 1.
Below is the implementation of the above approach:
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Find minimum number of coins that make a given value
- Find the minimum number of operations required to make all array elements equal
- Minimum number N such that total set bits of all numbers from 1 to N is at-least X
- Minimum number of letters needed to make a total of n
- Minimum number of distinct powers of 2 required to express a given binary number
- Minimum number of swaps required to make a number divisible by 60
- Minimum number of given powers of 2 required to represent a number
- Find the total number of composite factor for a given number
- Minimum number of operations required to reduce N to 0
- Minimum number operations required to convert n to m | Set-2
- Minimum number of operations required to reduce N to 1
- Minimum number of changes required to make the given array an AP
- Minimum number of palindromes required to express N as a sum | Set 2
- Minimum number of palindromes required to express N as a sum | Set 1
- Minimum number of primes required such that their sum is equal to N
- Minimum number of given operation required to convert n to m
- Minimum number of integers required such that each Segment contains at least one of them
- Find the total Number of Digits in (N!)N
- Minimum number of bottles required to fill K glasses
- Minimum count of numbers required ending with 7 to sum as a given number
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.