class Solution:
def maxSubArray(self, nums: list[int]) -> int:
result = acc = nums[0]
for i in range(1, len(nums)):
acc = max(nums[i], nums[i] + acc)
result = max(result, acc)
return result
53. Maximum Subarray - LeetCode
ยท One min read