Content deleted Content added
remove simple code variants -- WP is not a compendium of code samples |
fixups |
||
Line 75:
This version of the algorithm will return 0 if the input contains no positive elements (including when the input is empty).
The algorithm can be adapted to the case which disallows empty subarrays or to keep track of the starting and ending indices of the maximum subarray.
===Complexity===
The runtime complexity of Kadane's algorithm is <math>O(n)</math> and its space complexity is <math>O(1)</math>.{{sfn|Bentley|1989|p=74}}{{sfn|Gries|1982|p=211}}
== Generalizations ==
|