If I run the book code (which appears identical to the “solutions” code on this site) I see the following:
int m1 = findMaximumSubarray(Arrays.asList( 0, 0)); // returns 0
int m2 = findMaximumSubarray(Arrays.asList(-1,-1)); // returns 0 - what?
int m3 = findMaximumSubarray(Arrays.asList( 1, 1)); // returns 2
int m4 = findMaximumSubarray(Arrays.asList(-1, 1)); // returns 1
Why is a list of only two -1 values returning a max subarray sum of 0 instead of -1?