public int maxProfit(int[] prices) {
		if(prices == null || prices.length <= 1) return 0;
		int L = prices.length;
		int [] maxLeft = new int [L+1];
		int [] maxRight = new int [L+1];

		int curMin = prices[0];
		int maxL = -1;
		for(int i = 0; i < L; ++i){
			if(prices[i] - curMin > maxL){
				maxL = prices[i] - curMin;
			}
			maxLeft[i] = maxL;
			if(prices[i] < curMin) curMin = prices[i];
		}

		int curMax = prices[L-1];
		int maxR = -1;
		for(int i = L-1; i >= 0; --i){
			if(curMax - prices[i] > maxR){
				maxR = curMax - prices[i];
			}
			maxRight[i] = maxR;
			if(prices[i] > curMax) curMax = prices[i];
		}

		int res = -1;
		for(int i = 0; i < L; ++i){
			res = Math.max(res, maxLeft[i] + maxRight[i+1]);
		}
		return res;
	}