prices[i] is a stock price on day i. You may trade as often as you like but hold at most one share, and after you sell you cannot buy on the next day (cooldown of one day). Return the maximum profit.
For [1, 2, 3, 0, 2] the answer is 3 (buy at 1, sell at 2, cool down, buy at 0, sell at 2).
The starter code tries every action on every day. It is correct but too slow for many days.
Example 1
Input:
max_profit_cooldown([1, 2, 3, 0, 2])
Output:
3
Example 2
Input:
max_profit_cooldown([1])
Output:
0
0 <= len(prices) <= 3000000 <= prices[i] <= 1000No results yet
Run your code to check it against the examples, or submit to run every test.