public class Solution { public int FindGreatestSumOfSubArray(int[] array) { if (array == null || array.length < 1) { return 0; } int n = array.length; int sum = 0; int max = Integer.MIN_VALUE; for (int num : array) { sum += num; max = Math.max(max, sum); if (sum < 0) { sum = 0; } } return max; } }