float kadane()
{ int i;
int maxsofar = 0, current_max = 0;
for (i = 0; i < n; i++) {
current_max += x[i];
if (current_max < 0)
current_max = 0;
if (maxsofar < current_max)
maxsofar = current_max;
}
return maxsofar;
}
No comments:
Post a Comment