Best Time to Buy and Sell Stock with Cooldown

Asked at GEICO · Coding Questions · Difficulty: Medium

Given an integer array `prices` where `prices[i]` is the price of a given stock on the `i`th day, design an algorithm to find the maximum profit. You may complete as many transactions as you like (i.e., buy one and sell one share of the stock multiple times) with the following restrictions: after you sell your stock, you cannot buy stock on the next day (i.e., cooldown one day).

Loading the problem…