class Solution:
def maxSubArray(self, nums: List[int]) -> int:
# 设当前的和为 cur_sum
cur_sum = 0
res = nums[0]
for num in nums:
# 如果当前和大于0
if cur_sum > 0:
cur_sum += num
else:
cur_sum = num
res = max(res, cur_sum)
return res