My LeetCode grinding. Trying to do a problem a day.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

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]))