这是很经典的动态规划题:
public class Solution {
public int FindGreatestSumOfSubArray(int[] array) {
int ans = array[0];
int prev = array[0];
for(int i = 1; i < array.length; i++){
int curr = array[i];
if(prev > 0){
curr += prev;
}
ans = Math.max(ans, curr);
prev = curr;
}
return ans;
}
}