We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 7346473 commit a97d4e4Copy full SHA for a97d4e4
problems/322.coin-change.md
@@ -105,13 +105,14 @@ class Solution:
105
return - 1
106
dp = [[amount + 1 for _ in range(len(coins) + 1)]
107
for _ in range(amount + 1)]
108
- # 初始化第一行为0,其他为最大值(也就是amount + 1)
109
+ # 初始化第一行为0,其他为最大值(也就是amount + 1)
110
for j in range(len(coins) + 1):
111
dp[0][j] = 0
112
113
for i in range(1, amount + 1):
114
for j in range(1, len(coins) + 1):
115
+ # 注意:dp[i - coins[j - 1]][j] 含义是硬币无限取, dp[i - coins[j - 1]][j - 1] 的含义就变成了硬币最多取一次
116
if i - coins[j - 1] >= 0:
117
dp[i][j] = min(
118
dp[i][j - 1], dp[i - coins[j - 1]][j] + 1)
0 commit comments