最大子序和
解题思路:
class Solution { public int maxSubArray(int[] nums) { int len = nums.length; int sum = 0; int max = nums[0]; for(int i=0;i<len;++i){ if(sum+nums[i]>0){ sum += nums[i]; max = Math.max(max,sum); }else{ sum = 0; max = Math.max(max,nums[i]); } } return max; } }