Example 1maxProfitII()InputCopyprices = [7,1,5,3,6,4]OutputCopy7WhyBuy at 1, sell at 5, buy at 3, sell at 6.