LeetCode: Best Time to Buy and Sell Stock

Approach 1: Dynamical programming: MaxProfit[i] = Max( MaxProfit[i-1],
prices[i] - minPrice). minPrice is the lowest price within range
price[0] to price[i-1].