def maxSubArray(nums):
    curr_max = nums[0]
    res = nums[0]
    for i in range(1, len(nums)):
        curr_max = max(curr_max + nums[i], nums[i])
        res = max(res, curr_max)
    return res


print(maxSubArray([-3, 8, -2, 4, -5, 6]))

e07d71247f0a636c869dec3a5b1a1cc5f68a7607
<mask token>

def maxSubArray(nums):
    curr_max = nums[0]
    res = nums[0]
    for i in range(1, len(nums)):
        curr_max = max(curr_max + nums[i], nums[i])
        res = max(res, curr_max)
    return res


<mask token>

def maxSubArray(nums):
    curr_max = nums[0]
    res = nums[0]
    for i in range(1, len(nums)):
        curr_max = max(curr_max + nums[i], nums[i])
        res = max(res, curr_max)
    return res


print(maxSubArray([-3, 8, -2, 4, -5, 6]))
