MCPcopy Create free account
hub / github.com/ashishps1/awesome-leetcode-resources / KadaneAlgorithm

Class KadaneAlgorithm

patterns/python/kadane_algorithm.py:1–10  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1class KadaneAlgorithm:
2 def max_sub_array(self, nums):
3 current_sum = nums[0]
4 max_sum = nums[0]
5
6 for i in range(1, len(nums)):
7 current_sum = max(nums[i], current_sum + nums[i])
8 max_sum = max(max_sum, current_sum)
9
10 return max_sum

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected