Best Time to Buy/Sell Stock with Cooldown

Medium

📝 Description

Maximize profit with 1 day cooldown after sell

Input Format

Space-separated array of prices

Output Format

Maximum profit

Constraints

1 ≤ prices.length ≤ 5000

🔍 Sample Input

1 2 3 0 2
            

✅ Sample Output

3
            

Code Editor

Please login to run and submit code.

Shortcuts: Ctrl+Enter to submit, Ctrl+Shift+R to run