Search⌘ K
AI Features

Solution: Best Time to Buy and Sell Stock III

Solution: Best Time to Buy and Sell Stock III asks you to find the maximum profit from a stock-price array using at most two completed buy-and-sell transactions, with only one holding at a time.

Statement

You are given an array, prices, where prices[i] represents the stock price on day ii.

Determine the maximum profit you can achieve by making at most two transactions. Each ...