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;
}
};
时间: 2024-10-08 10:28:44