动态规划。
class Solution {
public:
int FindGreatestSumOfSubArray(vector<int> array) {
int sum = 0;
int maxsum = 0xFFFFFFFF;
int len = array.size();
if(len == 0)
return 0;
for(int i = 0; i < len; i++)
{
sum += array[i];
if(sum > maxsum)
{
maxsum = sum;
}
if(sum < 0)
sum = 0;
}
return maxsum;
}
};