public int maxProfit(int[] prices) {
		// special case, if there is no element in the array
		// we will fail to get pre;
		if (prices.length < 1)
			return 0;
		// previous price
		int pre = prices[0];
		int profit = 0;
		for (int i = 0; i < prices.length; i++) {
			if (prices[i] > pre) {
				// notice how this is calculated.
				profit += prices[i] - pre;
			}
			// buy today's stock
			pre = prices[i];
		}
		return profit;
	}