Skip to content

Commit

Permalink
新增java註解
Browse files Browse the repository at this point in the history
新增java註解
if statement的解釋
  • Loading branch information
Lozakaka authored Jun 8, 2023
1 parent accc97c commit 17a01ce
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions problems/0070.爬楼梯完全背包版本.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,13 @@ Java:
class Solution {
public int climbStairs(int n) {
int[] dp = new int[n + 1];
int m = 2;
int m = 2; //有兩個物品:itme1重量爲一,item2重量爲二
dp[0] = 1;
for (int i = 1; i <= n; i++) { // 遍历背包
for (int j = 1; j <= m; j++) { //遍历物品
if (i >= j) dp[i] += dp[i - j];
if (i >= j) //當前的背包容量 大於 物品重量的時候,我們才需要記錄當前的這個裝得方法(方法數+)
dp[i] += dp[i - j];
}
}
Expand Down

0 comments on commit 17a01ce

Please sign in to comment.