01 two numbers and
this question mainly to find out not understanding the problem as long as two and meet the target to return
if there is no direct return empty return vector
class Solution {
public:
vector<int> twoSum(vector<int>& nums, int target) {
int length=nums.size();
vector<int>result;
for(int i=0;i<length;i++){
for(int j=i+1;j<length;j++){
if( nums[i]+nums[j]==target)
result.push_back(i);
result.push_back(j);
return result;
}
}
return result;
}
};
02