Answers for "kadane algorithm with negative numbers included as sum"

C++
0

kadane algorithm with negative numbers included as sum

//Usually Kadene's algorithm is not considered for negative numbers.   
  int ms,cs;
	    ms=cs=a[0]; 
	    for(int i=1;i<n;i++)
	    {
	        cs=max(a[i],cs+a[i]);
	       ms=max(cs,ms);
	}
return ms;
Posted by: Guest on October-23-2020

Code answers related to "kadane algorithm with negative numbers included as sum"

Browse Popular Code Answers by Language