solution for best-time-to-buy-and-sell-stock-iii