My LeetCode grinding. Trying to do a problem a day.
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

1234567891011
  1. class Solution:
  2. def maxSubArray(self, nums):
  3. max_val = -1000000000000
  4. current = -1000000000000
  5. for n in nums:
  6. current = max(n, n + current)
  7. max_val = max(max_val, current)
  8. return max_val
  9. s = Solution()
  10. print(s.maxSubArray([8, -19, 5, -4, 20]))