MCPcopy Create free account
hub / github.com/Hsinha11/Leetcode-solutions / maxSubArray

Method maxSubArray

53-maximum-subarray/maximum-subarray.py:6–15  ·  view source on GitHub ↗
(self, nums: List[int])

Source from the content-addressed store, hash-verified

4
5class Solution:
6 def maxSubArray(self, nums: List[int]) -> int:
7 max_current = nums[0]
8 max_global = nums[0]
9
10 for i in range(1, len(nums)):
11 max_current = max(nums[i], max_current + nums[i])
12 if max_current > max_global:
13 max_global = max_current
14
15 return max_global

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected