Leetcode309. Best Time to Buy and Sell Stock with Cooldown

309. Best Time to Buy and Sell Stock with Cooldown 解题思路 可以分两种状态来维护,两个数组hold[]持有股票的最大收益和sold[]卖出股票的最大收益,持有股票状态与卖出股票状态的改变会相互影响。 Solution: DP (动态规划) hold[i] = max(hold[i-1], sold[i-2] – price[i]) (解释:持有股
相关文章
相关标签/搜索