题解 | #连续子数组的最大和#
连续子数组的最大和
http://www.nowcoder.com/practice/459bd355da1549fa8a49e350bf3df484
public class Solution {
public int FindGreatestSumOfSubArray(int[] array) {
int N = array.length;
int i = 0, tmp = 0, max = Integer.MIN_VALUE;
while(i < N) {
tmp += array[i];
max = Math.max(max, tmp);
if(tmp < 0) {
tmp = 0;
}
i++;
}
return max;
}
}

