public static int maxProfit4(int[] prices) {
		if (prices.length < 2) {
			return 0;
		}
		int[] left = new int[prices.length];
		int[] right = new int[prices.length];
		int min = prices[0];
		int max = prices[prices.length - 1];
		left[0] = 0;
		right[prices.length - 1] = 0;

		for (int i = 1; i < prices.length; i++) {
			if (prices[i] < min)
				min = prices[i];
			left[i] = prices[i] - min > left[i - 1] ? prices[i] - min
					: left[i - 1];
		}

		for (int i = prices.length - 2; i >= 0; i--) {
			if (prices[i] > max)
				max = prices[i];
			right[i] = max - prices[i] > right[i + 1] ? max - prices[i]
					: right[i + 1];
		}

		int total = 0;
		for (int i = 0; i < prices.length; i++) {
			total = left[i] + right[i] > total ? left[i] + right[i] : total;
		}
		return total;
	}