public int maxProfit(int[] prices) {
		if(prices == null || prices.length == 0) return 0;
		int[] firstTrans = new int[prices.length];
		int min = prices[0], max = prices[prices.length-1], maxTotal;
		
		for(int i = 1; i < prices.length; i++) {
			if(prices[i] - min > firstTrans[i-1]) firstTrans[i] = prices[i] - min;
			else firstTrans[i] = firstTrans[i-1];
			if(prices[i] < min) min = prices[i];
		}
		maxTotal = firstTrans[prices.length - 1];
		
		for(int i = prices.length - 2; i > 0; i--) {
			if(max - prices[i] + firstTrans[i - 1] > maxTotal) {
				maxTotal = max - prices[i] + firstTrans[i - 1];
			}
			if(prices[i] > max) max = prices[i];
		}
		return maxTotal;
	}