start from left one can find we only need to check weather current sum is larger or smaller than zero. If smaller, we can re-start at right position.

```
class Solution(object):
def maxSubArray(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
if not nums: return nums
maxsum = nums[0]
cursum = 0
for i in range(len(nums)):
cursum += nums[i]
maxsum = max(maxsum,cursum)
if cursum < 0:
cursum = 0
return maxsum
```