LeetCode 1. 两数之和
原题链接
class Solution {
public:
vector<int> twoSum(vector<int>& s, int t) {
vector <int>ans;
for (int i=0;i<s.size();i++){
for (int j=i+1;j<s.size();j++){
if (s[i]+s[j]==t){
ans.push_back(i);
ans.push_back(j);
return ans;
}
}
}
return ans;
}
};