public class Solution {
public int maxSubArray(int[] nums) {
if (nums == null || nums.length == 0) {
return 0;
}
int length = nums.length;
int sum = 0;
int result = Integer.MIN_VALUE;
for (int i = 0; i < length; i++) {
if (sum < 0) {
sum = 0;
}
sum += nums[i];
result = result > sum ? result : sum;
}
return result;
}
}