Can anyone Tell me what is wrong?


#1

int Solution::maxSubArray(const vector &A) {
int i;
int sum=0 ;
int max_sum = 0;
int N=0;
for(auto N:A){
N++;
}

for(i=0; i<=N; i++){
    sum += A[i];
    max_sum = max(sum,max_sum);
}

return max_sum;

}


#2

try taking max_sum=INT_MIN;
hope it’ll work :slight_smile: