class Solution {
public:
/*
* @param nums: a list of integers
* @return: A integer indicate the sum of minimum subarray
*/
int minSubArray(vector<int> &nums) {
// write your code here
int s=nums.size();
int res=nums[0];
for(int i=0;i<s;i++)
{
int cn=nums[i];
if(cn<res)
res=cn;
for(int j=i+1;j<s;j++)
{
cn+=nums[j];
if(cn<=res)
res=cn;
}
}
return res;
}
};
class Solution {
public:
/*
* @param nums: a list of integers
* @return: A integer indicate the sum of minimum subarray
*/
int minSubArray(vector<int> &nums) {
// write your code here
int s=nums.size();
int res=nums[0];
int cn=0;
for(int i=0;i<s;i++)
{
cn +=nums[i];
if(res>cn)
res=cn;
if(cn>0)
cn=0;
}
return res;
}
};