mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-08 00:22:55 +08:00
Merge pull request #1218 from samwulol/master
修正【0122-买卖股票的最佳时机II.md】javaScript代码
This commit is contained in:
@ -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];
|
||||
};
|
||||
```
|
||||
|
||||
|
@ -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];
|
||||
};
|
||||
|
||||
// 方法二:动态规划(滚动数组)
|
||||
|
Reference in New Issue
Block a user