# leetcode53.最大子数组和-滑动窗口

```golang
func maxSubArray(nums []int) int {
    l,r:=0,0
    winSum,maxSum:=0,-1<<31
    
    for r<len(nums){
        winSum+=nums[r]
        r++
        
        if winSum>maxSum{
            maxSum=winSum
        }
        
        for winSum<0{
            winSum-=nums[l]
            l++
        }
    }
    return maxSum

}
```
