Skip to content

Commit

Permalink
Merge pull request youngyangyang04#2128 from Lozakaka/patch-20
Browse files Browse the repository at this point in the history
新增java註解
  • Loading branch information
youngyangyang04 authored Jun 28, 2023
2 parents eb92cb0 + 17a01ce commit f975588
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 f975588

Please sign in to comment.