Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import math
- class Solution:
- def maxSubArray(self, nums: List[int]) -> int:
- current_max = -math.inf
- if len(nums) == 0:
- return current_max
- current_sum = 0
- for i in range(0, len(nums)):
- current_sum += nums[i]
- current_max = max(current_sum, current_max)
- if current_sum < 0:
- current_sum = 0
- return current_max
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement