This question evaluates algorithmic optimization and combinatorial reasoning in the coin-change domain, measuring proficiency with efficient numeric manipulation, counting strategies, and handling of fixed coin denominations.
You have an unlimited number of coins with denominations:
1, 5, 10, 50, 100, 200
You need to pay exactly n units to another person. You are allowed to overpay, and the other person will always be able to give you exact change (they also have unlimited coins).
Define the total coins used as:
Return the minimum possible total number of coins needed to complete the transaction.
n
.
Input:
41
Output:
3
Explanation: Pay 50 + 1 (2 coins) and receive 10 as change (1 coin), total 2 + 1 = 3.
0 ≤ n ≤ 10^9
.