class Solution {
public:
int maxSubArray(vector<int>& nums) {
//动规的思想
int res = INT_MIN,s = 0;
for(auto x:nums){
if(s < 0) s = 0;
s += x;
res = max(s,res);
}
return res;
}
};