public class Solution {

public int maxSubArray(int[] nums) {

if(nums == null || nums.length<1){

return 0;

}

int max = nums[0];

int tmp = 0;

for(int i=1;i<nums.length;i++){

tmp = nums[i-1]+nums[i];

nums[i] = nums[i]>tmp?nums[i]:tmp; //compare nums[i] and nums[i-1]+nums[i] ,which is the bigest

if(max < nums[i]){

max = nums[i];

}

}

return max;

}

}