public int maxSubArray2(int[] A) {// O(1) space

		if (A == null)
			return 0;
		int last = A[0];
		int max = last;
		for (int i = 1; i < A.length; i++) {
			last = Math.max(A[i], last + A[i]);
			max = Math.max(last, max); // keep track of the largest sum
		}
		return max;
	}