Skip to content

Latest commit

 

History

History
15 lines (15 loc) · 329 Bytes

53.md

File metadata and controls

15 lines (15 loc) · 329 Bytes

解法一

  • 60ms
  • 97%
class Solution:
    def maxSubArray(self, nums: List[int]) -> int:
        maxSum = curSum = nums[0]
        for n in nums[1:]:
            if curSum < 0:
                curSum = n
            else:
                curSum += n
            maxSum = max(maxSum, curSum)
        return maxSum