mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-10 20:40:39 +08:00
fix:0123.买卖股票的最佳时机III =》错误修改
This commit is contained in:
@ -242,9 +242,9 @@ class Solution {
|
|||||||
|
|
||||||
for (int i = 1; i < len; i++) {
|
for (int i = 1; i < len; i++) {
|
||||||
dp[i][1] = Math.max(dp[i - 1][1], -prices[i]);
|
dp[i][1] = Math.max(dp[i - 1][1], -prices[i]);
|
||||||
dp[i][2] = Math.max(dp[i - 1][2], dp[i][1] + prices[i]);
|
dp[i][2] = Math.max(dp[i - 1][2], dp[i - 1][1] + prices[i]);
|
||||||
dp[i][3] = Math.max(dp[i - 1][3], dp[i][2] - prices[i]);
|
dp[i][3] = Math.max(dp[i - 1][3], dp[i - 1][2] - prices[i]);
|
||||||
dp[i][4] = Math.max(dp[i - 1][4], dp[i][3] + prices[i]);
|
dp[i][4] = Math.max(dp[i - 1][4], dp[i - 1][3] + prices[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return dp[len - 1][4];
|
return dp[len - 1][4];
|
||||||
|
Reference in New Issue
Block a user