Permalink
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
31 lines (28 sloc) 743 Bytes
// #include <iostream>
// #include <vector>
// using namespace std;
class Solution {
public:
vector<int> twoSum(vector<int>& nums, int target) {
vector<int> n(2);
for(int a = 0;a < nums.size();a++){
for(int b = a + 1;b < nums.size();b++){
if(nums[a] + nums[b] == target){
n[0] = a;
n[1] = b;
return n;
}
}
}
}
};
// int main() {
// int a[] = {2, 7, 11, 15};
// int b = 9;
// int size = sizeof(a) / sizeof(int) ;
// vector<int> c(a, a+size);
// Solution S1;
// vector<int> r = S1.twoSum(c, b);
// cout << "a:" << r[0] << " b:" << r[1] << endl;
// return 0;
// }