File tree Expand file tree Collapse file tree 1 file changed +4
-4
lines changed
Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change 11"""
22Kadane's Algorithm implementation in Python.
33
4- Finds the maximum sum of a contiguous subarray within a one-dimensional array of numbers.
4+ Finds the maximum sum of a contiguous subarray within
5+ a one-dimensional array of numbers.
56
67Source:
78https://en.wikipedia.org/wiki/Maximum_subarray_problem
89"""
910
1011
11- def kadane (arr ) :
12+ def kadane (arr : list [ int ]) -> tuple [ int , list [ int ]] :
1213 """
1314 Returns the maximum sum of a contiguous subarray and the subarray itself.
1415
@@ -51,11 +52,10 @@ def kadane(arr):
5152 start = s
5253 end = i
5354
54- return max_global , arr [start : end + 1 ]
55+ return max_global , arr [start : end + 1 ]
5556
5657
5758# Doctest runner
5859if __name__ == "__main__" :
5960 import doctest
60-
6161 doctest .testmod ()
You can’t perform that action at this time.
0 commit comments