diff --git a/problems/0122.买卖股票的最佳时机II.md b/problems/0122.买卖股票的最佳时机II.md index 4f585a3c..78aa5952 100644 --- a/problems/0122.买卖股票的最佳时机II.md +++ b/problems/0122.买卖股票的最佳时机II.md @@ -264,7 +264,7 @@ const maxProfit = (prices) => { dp[i][1] = Math.max(dp[i-1][1], dp[i-1][0] + prices[i]); } - return dp[prices.length -1][0]; + return dp[prices.length -1][1]; }; ``` diff --git a/problems/0122.买卖股票的最佳时机II(动态规划).md b/problems/0122.买卖股票的最佳时机II(动态规划).md index 615d79bb..5a165a14 100644 --- a/problems/0122.买卖股票的最佳时机II(动态规划).md +++ b/problems/0122.买卖股票的最佳时机II(动态规划).md @@ -276,7 +276,7 @@ const maxProfit = (prices) => { dp[i][1] = Math.max(dp[i-1][1], dp[i-1][0] + prices[i]); } - return dp[prices.length -1][0]; + return dp[prices.length -1][1]; }; // 方法二:动态规划(滚动数组)