From 6498ee65f7d9d38e59d3e338bdbec9a79cb6a438 Mon Sep 17 00:00:00 2001 From: zdz <2549626703@qq.com> Date: Tue, 23 May 2023 22:36:43 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A0123.=E4=B9=B0=E5=8D=96=E8=82=A1?= =?UTF-8?q?=E7=A5=A8=E7=9A=84=E6=9C=80=E4=BD=B3=E6=97=B6=E6=9C=BAIII=20=3D?= =?UTF-8?q?=E3=80=8B=E9=94=99=E8=AF=AF=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- problems/0123.买卖股票的最佳时机III.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/problems/0123.买卖股票的最佳时机III.md b/problems/0123.买卖股票的最佳时机III.md index af6870d4..6ac9a576 100644 --- a/problems/0123.买卖股票的最佳时机III.md +++ b/problems/0123.买卖股票的最佳时机III.md @@ -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];