Simple C++ Solution using KADANE'S Algorithm


#1

int Solution::maxSubArray(const vector &A) {
int sum=0;
int maxSum = INT_MIN;
for(int i=0;i<A.size();i++){
sum+=A[i];
sum=max(A[i],sum);
maxSum = max(sum,maxSum);
}
return maxSum;
}