/*
当便利到A的时候, A左面的最大连续子树和total 
if (total > 0) {
    total += A
} else{
    total = A;
}
sum = max(sum, total);

*/
class Solution {
public:
    int FindGreatestSumOfSubArray(vector<int> array) {
        int len = array.size(), sum = array[0], total = array[0];
        for (int i = 1; i < len; i++) {
             if (total > 0) {
                 total += array[i];
             } else {
                 total = array[i];
             }
             sum = (sum > total) ? sum : total;
         }
        return sum;
    }
    
};