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