Best Time to Buy and Sell Stock 3

DP is OK, but different DP can cause different problems:
Memory Limit Exceeded/ Time Limit Exceeded. O(n^2)
Finally, O(n) is AC