Best Time to Buy and Sell Stock with Cooldown
Medium
Topics
Given daily stock prices, maximize profit with as many transactions as you like, but after you sell you must cooldown one day before buying again. Return the max profit.
Example 1
Input: prices = [1,2,3,0,2] Output: 3 Explanation: buy, sell, cooldown, buy, sell.
Example 2
Input: prices = [1] Output: 0
Constraints
- 1 <= prices.length <= 5000
- 0 <= prices[i] <= 1000
Run ⌘' · Submit ⌘⏎