class Solution:
    def maxSubArray(self, nums: List[int]) -> int:

        maxSub = nums[0]
        curSum = 0

        for n in nums:
            if curSum < 0:
                curSum = 0

            curSum += n
            maxSub = max(curSum, maxSub)

        return maxSub

        ## TC: O(n), SC: O(1)
