标签:最大和 剑指offer for int return vector test sum 连续
class Solution {
public:
int FindGreatestSumOfSubArray(vector<int> array) {
int maxNum =0x80000000;
int curNum = 0;
for(int i=0; i<array.size(); i++)
{
if(curNum <= 0)
curNum = array[i];
else
curNum += array[i];
if(curNum > maxNum)
maxNum = curNum;
}
return maxNum;
}
};
标签:最大和 剑指offer for int return vector test sum 连续
原文地址:http://www.cnblogs.com/shewell/p/6493008.html