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