Movatterモバイル変換


[0]ホーム

URL:


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

Commitcfd7b05

Browse files
refactor 714
1 parent9e8957b commitcfd7b05

File tree

1 file changed

+2
-2
lines changed
  • src/main/java/com/fishercoder/solutions

1 file changed

+2
-2
lines changed

‎src/main/java/com/fishercoder/solutions/_714.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ public int maxProfit(int[] prices, int fee) {
4040
intcash =0;
4141
inthold = -prices[0];
4242
for (inti =1;i <prices.length;i++) {
43-
cash =Math.max(cash,hold +prices[i] -fee);
44-
hold =Math.max(hold,cash -prices[i]);
43+
cash =Math.max(cash,hold +prices[i] -fee);//this means to sell the stock: gain the current ith day's price and pay the transaction fee
44+
hold =Math.max(hold,cash -prices[i]);//this means to buy in this stock on the ith day's price.
4545
}
4646
returncash;
4747
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp