题解 | #连续子数组的最大和#
连续子数组的最大和
http://www.nowcoder.com/practice/459bd355da1549fa8a49e350bf3df484
public:
int FindGreatestSumOfSubArray(vector<int> array) {
int i,res=-1;
for(i=0;i<array.size();i++){
if(i==0) res=array[i];
else{
if(array[i-1]>0) array[i]+=array[i-1];
res=max(res,array[i]);
}
}
return res;
}
};