123. Best Time to Buy and Sell Stock III
https://leetcode.com/problems/best-time-to-buy-and-sell-stock-iii/
Problem
Say you have an array for which the ith element is the price of a given stock on day i.
Design an algorithm to find the maximum profit. You may complete at most two transactions.
Note: You may not engage in multiple transactions at the same time (i.e., you must sell the stock before you buy again).
Example 1:
Example 2:
Example 3:
Example 4:
Constraints:
1 <= prices.length <= 105
0 <= prices[i] <= 105
Solution
#dp
Last updated
Was this helpful?