Best Time to Buy and Sell Stock With Cooldown

Medium · Dynamic Programming · about 25 minutes

Asked at Google, Amazon, Bloomberg, Coinbase, Citadel, Capital One, SoFi.

prices[i] is a share's price on day i. You may buy and sell as often as you like, holding at most one share at any time. After a sale, though, you have to skip the following day before you may buy again. What's the largest total profit?

Related guides