The array prices shows the price of one share on each day: prices[i] is the price on day i.
You may buy and sell the share, but you can make at most two trades (a trade is one buy followed by one sell). You can hold only one share at a time, so you must sell before you buy again.
Return the biggest profit you can make. If you cannot make any profit, return 0.
Examples
Example 1:
Input: prices = [2,5,1,6,3,8]
Output: 10
Explanation: Buy at 2 and sell at 5 (profit 3). Then buy at 1 and sell at 8 (profit 7). The total is 10.
Example 2:
Input: prices = [1,2,3,4]
Output: 3
Explanation: Buy at 1 and sell at 4 for a profit of 3. A second trade gives nothing more.
Example 3:
Input: prices = [9,7,5]
Output: 0
Explanation: The price only falls, so it is best not to trade.