Fix the content

This commit is contained in:
krahets
2023-08-10 11:35:16 +08:00
parent 932d14644d
commit 6ef4dc6444
10 changed files with 14 additions and 14 deletions

View File

@ -13,7 +13,7 @@ def coin_change_greedy(coins: list[int], amt: int) -> int:
# 循环进行贪心选择,直到无剩余金额
while amt > 0:
# 找到小于且最接近剩余金额的硬币
while coins[i] > amt:
while i > 0 and coins[i] > amt:
i -= 1
# 选择 coins[i]
amt -= coins[i]