We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e426fbe commit 87010e1Copy full SHA for 87010e1
1 file changed
dynamic_programming/kadane_algorithm.py
@@ -1,14 +1,15 @@
1
"""
2
Kadane's Algorithm implementation in Python.
3
4
-Finds the maximum sum of a contiguous subarray within a one-dimensional array of numbers.
+Finds the maximum sum of a contiguous subarray within
5
+a one-dimensional array of numbers.
6
7
Source:
8
https://en.wikipedia.org/wiki/Maximum_subarray_problem
9
10
11
-def kadane(arr):
12
+def kadane(arr: list[int]) -> tuple[int, list[int]]:
13
14
Returns the maximum sum of a contiguous subarray and the subarray itself.
15
@@ -51,11 +52,10 @@ def kadane(arr):
51
52
start = s
53
end = i
54
- return max_global, arr[start : end + 1]
55
+ return max_global, arr[start:end+1]
56
57
58
# Doctest runner
59
if __name__ == "__main__":
60
import doctest
-
61
doctest.testmod()
0 commit comments