cpp implementation of Best Time To Buy And Sell Stock III