Practice Best Time to Buy and Sell Stock with Cooldown
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
The array prices gives the stock price on each day. Find the maximum total profit from any number of buy-and-sell transactions, holding at most one share at a time. After selling, you must wait through the next day before buying again. Sell the current share before making another purchase.
Source: Best Time to Buy and Sell Stock with Cooldown on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
prices = [1,2,3,0,2]
3
# Example 2
prices = [1]
0
Constraints
Related LeetCode Problems
Practice more problems similar to Best Time to Buy and Sell Stock with Cooldown.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.