解题思路 解题思路public int maxSubArray(int[] nums) { if(nums==null||nums.length==0) return 0; int maxRes = Integer.MIN_VALUE; int sum = 0; for(int val:nums){ if(sum<=0) sum = val; else sum += val; maxRes = Math.max(maxRes, sum); } return maxRes; }