Buy and stock ||| pls explain this

cant’t undertand this problem

hi @divisharoy14_5d0aa86c37c6588a,
you have to sell 2 stocks one after another and make maximum profit.
You are given an array price where prices[i] denotes the price of a stock on the ith day. You want to maximize the profit by buying a stock and then selling it at a higher price.

Suppose you can do at most two transactions (two buys and two sells), what is the maximum profit that you can make?

Note:

  • Return 0 if you cannot make a profit.
  • You cannot buy/hold more than 1 stock at a time.
  • You need to sell a stock before buying again.
  • You can sell a stock and buy it again on the same day.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.