Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[pull] master from youngyangyang04:master #294

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
pull merged 6 commits into AlgorithmAndLeetCode:master from youngyangyang04:master
Jun 28, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
新增java註解
新增java註解
if statement的解釋
  • Loading branch information
Lozakaka authored Jun 8, 2023
commit 17a01cecefcdb2b71806a56bc6789686bcb755ac
5 changes: 3 additions & 2 deletions problems/0070.爬楼梯完全背包版本.md
View file Open in desktop
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

AltStyle によって変換されたページ (->オリジナル) /