Profit after selling a 2 stocks should be maximum as possible . profit2 tracks maximum possible profit we can make from 0 to i - 1.
profit2 = max ( profit2 , price [ i ] - buy2 ) ; } return profit2 ; }