class Solution {
public:
int maxSubArray(vector<int>& nums) {
if(nums.size() == 1){
return nums[0];
}
int sum = 0;
int ans = INT_MIN;
int i=0;
for(i=0;i<nums.size();i++){
if(sum<0){
sum = nums[i];
//continue;
}else{
sum += nums[i];
}
ans = max(ans,sum);
}
return ans;
}
};