Content deleted Content added
→Empty subarrays admitted: more clarity: first consider the problem, then the algorithm |
→Empty subarrays admitted: fix misunderstanding: described changes obtain the algorithm variant |
||
Line 79:
Kadane's algorithm, as originally published, is for solving the problem variant which allows empty subarrays.{{sfn|Bentley|1989|p=74}}{{sfn|Gries|1982|p=211}}
In such variant, the answer is 0 when the input contains no positive elements (including when the input is empty).
The
<syntaxhighlight lang="python" line start="3">
best_sum = 0;
|