```
class Solution {
public:
vector<int> twoSum(vector<int>& nums, int target) {
unordered_map<int, int> m;
for (int i = 0; i < nums.size(); ++i) {
int j = m[target - nums[i]];
if (j) return {j - 1, i};
m[nums[i]] = i + 1;
}
return {-1, -1};
}
};
```