My LeetCode grinding. Trying to do a problem a day.
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

main.py 304B

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