Minimum US Coins
EasyGreedyMath
Description
Given a non-negative integer n cents, return the minimum number of US coins (denominations 25, 10, 5, 1) needed to make exactly n cents. A greedy approach works because of the denomination structure.
Examples
Input:
n = 41Output:
4Explanation:
25 + 10 + 5 + 1 = 4 coins.
Input:
n = 0Output:
0Explanation:
Zero cents needs zero coins.
Input:
n = 99Output:
9Explanation:
3*25 + 2*10 + 0*5 + 4*1 = 9 coins.
Constraints
- •
0 ≤ n ≤ 10⁹