Canonical coin change
You are given an amount and a list of coin denominations that always includes 1 and is canonical, meaning repeatedly taking the largest coin that still fits always yields an optimal answer (as with [1, 5, 10, 25]). Return the minimum number of coins needed to make exactly the amount. Example: amount 63 with coins [1, 5, 10, 25] needs 6 coins (25 + 25 + 10 + 1 + 1 + 1). An amount of 0 needs 0 coins.
Implement
min_coins(amount: int, coins: list[int]) → intExamples
in
[63,[1,5,10,25]]out6What a strong answer looks like
State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.
0:00 of about 10 min
solution.py
InputExpectedGot
[63,[1,5,10,25]]6not run yetsample