非常简单的if-else
public class Solution {
public int FindGreatestSumOfSubArray(int[] array) {
if(array.length == 0) {
return 0;
}
int temp = 0;
int max = Integer.MIN_VALUE;
for(int x : array) {
if(temp < 0) {
temp = x;
} else {
temp += x;
}
max = Math.max(temp, max);
}
return max;
}
}