rewrite leetcode best time to buy and sell stocks i ii iii