int MaxSubSum3(int *arr, int len) {
int i;
long long MaxSum = 0;
long long CurSum = 0;
for(int i = 0; i < len; i ++) {
CurSum += arr[i];
if(CurSum > MaxSum)
MaxSum = CurSum;
if(CurSum < 0)
CurSum = 0;
}
return MaxSum;
}
2024-01-17 14:10:22
int MaxSubSum3(int *arr, int len) {
int i;
long long MaxSum = 0;
long long CurSum = 0;
for(int i = 0; i < len; i ++) {
CurSum += arr[i];
if(CurSum > MaxSum)
MaxSum = CurSum;
if(CurSum < 0)
CurSum = 0;
}
return MaxSum;
}