Skip to main content
Best Time to Buy and Sell Stock with Cooldown | AlgoCracked
AlgoCracked
ProblemsBest Time to Buy and Sell Stock with Cooldown
Medium57.0% acceptance
Dynamic ProgrammingArray

Best Time to Buy and Sell Stock with Cooldown

You are given an array prices where prices[i] is the price of a stock on day i . You may complete as many transactions as you like (buy then sell), but you can only hold one share at a time and you may not buy on the day right after a sale (a one-day cooldown). Return the maximum profit you can achieve. Input format Input is a single array, e.g. [[1,2,3,0,2]] .

Loading workspace…