Skip to content

Commit cc8c57e

Browse files
增加了注释
1 parent a5b3ee2 commit cc8c57e

File tree

4 files changed

+23
-53
lines changed

4 files changed

+23
-53
lines changed

.idea/workspace.xml

Lines changed: 18 additions & 53 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
-32 Bytes
Binary file not shown.
Binary file not shown.

src/leetcode/CoinChange.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,22 @@ private int CoinChange(int[] coins, int amount) {
3030
for (int i = 1; i <= amount; i++) {
3131
int res = Integer.MAX_VALUE;
3232
for (int j = 0; j < coins.length; j++) {
33+
// 如果该值大于i,就直接继续
3334
if (coins[j] > i) {
3435
continue;
3536
}
37+
// 如果该值等于-1,直接继续
3638
if (dp[i - coins[j]] == -1) {
3739
continue;
3840
}
41+
// 状态转移方程
3942
dp[i] = 1 + dp[i - coins[j]];
4043
res = Math.min(res, dp[i]);
4144
}
45+
// 取出dp中最小的一个
4246
dp[i] = res;
4347
}
48+
// 然后返回dp[amount]
4449
return dp[amount];
4550
}
4651
}

0 commit comments

Comments
 (0)