Solution for best time to buy and sell