子数组之和
class Solution {
public:
/**
* @param nums: A list of integers
* @return: A list of integers includes the index of the first number
* and the index of the last number
*/
vector<int> subarraySum(vector<int> nums){
// write your code here
int len=nums.size();
vector<int> vec;
for(int i= 0; i<len;i++){
int subsum=nums[i];
if(nums[i]==0){
vec.push_back(i);
vec.push_back(i);
return vec;
}
for(int j=i+1;j<len;j++){
subsum+=nums[j];
if(subsum==0){
vec.push_back(i);
vec.push_back(j);
return vec;
}
}
}
}
};