309. Best Time to Buy and Sell Stock with Cooldown
Input: [1,2,3,0,2]
Output: 3
Explanation: transactions = [buy, sell, cooldown, buy, sell]sells[i]表示在第i天不持有股票所能获得的最大累计收益
buys[i]表示在第i天持有股票所能获得的最大累计收益
初始化数组:
sells[0] = 0
buys[0] = -prices[0]
buys[1] = max(-prices[0], -prices[1]) 第1天有股票,只可能是第0天或者第1天买入的Previous714. Best Time to Buy and Sell Stock with Transaction FeeNext123. Best Time to Buy and Sell Stock III
Last updated