Best Time to Buy and Sell Stock III
Hard · Dynamic Programming · about 25 minutes
Asked at Meta, Amazon, Google, Bloomberg, Snap.
prices[i] is a stock's price on day i. Make at most two transactions (buy then sell; you can't hold two shares at once). Return the maximum profit.