Skip to content

Commit fdaf14b

Browse files
authored
Batch-3/Neetcode-All/Added-articles (neetcode-gh#3765)
1 parent dd3a60f commit fdaf14b

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 i in range(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
int dp_buy = Math.Max(dp1_sell - prices[i], dp1_buy);
720717
int dp_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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy