wiki maximum subarray problem code example
Example: kadane algorithm actual
//Kadene's algorithm where empty array is allowed.
int ms,cs;
ms=cs=0;
for(int i=0;i<n;i++)
{
cs=cs+a[i];
if(cs<0)
{
cs=0;
}
ms=max(ms,cs);
}
cout<<ms<<endl;
}