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;
}
}