14 / 15 test cases passed.

Status: Wrong Answer

Submitted: 0 minutes ago

Input: [3,2,4], 6

Output: 1, 1

Expected: 2, 3

class Solution {

public:

vector<int> twoSum(vector<int> &numbers, int target) {

vector<int> result;

map<int, int> hashmap;

for (int i = 0; i < numbers.size(); i++) {

hashmap[numbers[i]] = i;

}

for (int j = 0; j < numbers.size(); j++) {

if (hashmap.find(target - numbers[j]) != hashmap.end()) {

cout << "works";

result.push_back(j + 1);

result.push_back(hashmap[target - numbers[j]] + 1);

break;

}

}

return result;

}

};