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

Commitfdaf14b

Browse files
authored
Batch-3/Neetcode-All/Added-articles (neetcode-gh#3765)
1 parentdd3a60f commitfdaf14b

File tree

23 files changed

+7982
-6
lines changed

23 files changed

+7982
-6
lines changed

‎articles/buy-and-sell-crypto-with-cooldown.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,7 @@ class Solution:
634634
for iinrange(n-1,-1,-1):
635635
dp_buy=max(dp1_sell- prices[i], dp1_buy)
636636
dp_sell=max(dp2_buy+ prices[i], dp1_sell)
637-
dp2_buy, dp1_sell= dp1_buy, dp1_sell
637+
dp2_buy= dp1_buy
638638
dp1_buy, dp1_sell= dp_buy, dp_sell
639639

640640
return dp1_buy
@@ -651,7 +651,6 @@ public class Solution {
651651
int dp_buy=Math.max(dp1_sell- prices[i], dp1_buy);
652652
int dp_sell=Math.max(dp2_buy+ prices[i], dp1_sell);
653653
dp2_buy= dp1_buy;
654-
dp1_sell= dp1_sell;
655654
dp1_buy= dp_buy;
656655
dp1_sell= dp_sell;
657656
}
@@ -673,7 +672,6 @@ public:
673672
int dp_buy = max(dp1_sell - prices[i], dp1_buy);
674673
int dp_sell = max(dp2_buy + prices[i], dp1_sell);
675674
dp2_buy = dp1_buy;
676-
dp1_sell = dp1_sell;
677675
dp1_buy = dp_buy;
678676
dp1_sell = dp_sell;
679677
}
@@ -698,7 +696,6 @@ class Solution {
698696
let dp_buy=Math.max(dp1_sell- prices[i], dp1_buy);
699697
let dp_sell=Math.max(dp2_buy+ prices[i], dp1_sell);
700698
dp2_buy= dp1_buy;
701-
dp1_sell= dp1_sell;
702699
dp1_buy= dp_buy;
703700
dp1_sell= dp_sell;
704701
}
@@ -719,7 +716,6 @@ public class Solution {
719716
intdp_buy=Math.Max(dp1_sell-prices[i],dp1_buy);
720717
intdp_sell=Math.Max(dp2_buy+prices[i],dp1_sell);
721718
dp2_buy=dp1_buy;
722-
dp1_sell=dp1_sell;
723719
dp1_buy=dp_buy;
724720
dp1_sell=dp_sell;
725721
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp