Tap here to switch tabs
Problem
Submissions

Problem: Best Time to Buy and Sell Stock with Cooldown

med
30 min
Try to solve the Best Time to Buy and Sell Stock with Cooldown problem.

Statement

You are given an integer array prices where prices[i] is the price of a given stock on day i.

Find the maximum profit you can achieve by completing as many transactions as you like.

Note:
You cannot engage in multiple transactions simultaneously, which means you must sell the stock before buying again.
After you sell your stock, you cannot buy stock on the immediately following day due to a cooldown of 11 day.

Constraints:

  • 1≤1 \leq prices.length ≤5000\leq 5000

  • 0≤0 \leq prices[i] ≤1000\leq 1000

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Best Time to Buy and Sell Stock with Cooldown

med
30 min
Try to solve the Best Time to Buy and Sell Stock with Cooldown problem.

Statement

You are given an integer array prices where prices[i] is the price of a given stock on day i.

Find the maximum profit you can achieve by completing as many transactions as you like.

Note:
You cannot engage in multiple transactions simultaneously, which means you must sell the stock before buying again.
After you sell your stock, you cannot buy stock on the immediately following day due to a cooldown of 11 day.

Constraints:

  • 1≤1 \leq prices.length ≤5000\leq 5000

  • 0≤0 \leq prices[i] ≤1000\leq 1000