标签:
public class Solution { public int maxSubArray(int[] nums) { int len=nums.length; if(len==0) return 0; int res=0; int[] results=new int[len]; for(int i=0;i<len;i++) { if(i==0) { results[0]=nums[0]; res=results[0]; } else { if(results[i-1]<0) results[i]=nums[i]; else results[i]=results[i-1]+nums[i]; if(results[i]>res) res=results[i]; } } return res; } }
标签:
原文地址:http://www.cnblogs.com/aguai1992/p/5352972.html