Solve the 'buy and sell stock III' problem in leetcode in O(n).