题解 | #连续子数组的最大和#
连续子数组的最大和
http://www.nowcoder.com/practice/459bd355da1549fa8a49e350bf3df484
public class Solution { public int FindGreatestSumOfSubArray(int[] array) { int len =array.length; int[] dp = new int[len]; dp[0] =array[0]; for(int i=1;i<len;i++){ dp[i]=Math.max(array[i],array[i]+dp[i-1]); } int maxNum =Integer.MIN_VALUE; for(int j=0;j<len;j++){ maxNum = maxNum>dp[j]?maxNum:dp[j]; } return maxNum; } }