public int maxProfit1(int[] prices) {
		int maxProfit = 0;
		if (prices.length <= 1)
			return maxProfit;

		if (prices.length == 2) {
			int profit = prices[1] - prices[0];
			if (profit > maxProfit)
				maxProfit = profit;
			return maxProfit;
		}

		// have at least three members
		for (int midIndex = 0; midIndex < prices.length; midIndex++) {
			int leftPartProfit = maxProfitRange(0, midIndex, prices);
			int rightPartProfit = maxProfitRange(midIndex + 1,
					prices.length - 1, prices);

			int curProfit = leftPartProfit + rightPartProfit;
			if (curProfit > maxProfit)
				maxProfit = curProfit;
		}

		return maxProfit;
	}