Best Time to Buy and Sell Stock III

You are given an array named prices where each element represents the price of a stock on a given day. Your task is to determine the maximum profit you can achieve by completing at most two transactions. Remember, you cannot hold multiple stocks simultaneously; you must sell before buying again.

Constraints

  • 1 <= prices.length <= 100000
  • 0 <= prices[i] <= 100000
Auto-saved · 2 lines
class Solution:
def maxProfit(self, prices: List[int]) -> int:
Console

Click Run to execute sample tests.