Infosys interview question

Stock buy and sell problem