class Solution {
public:
vector<int> twoSum(vector<int>& numbers, int target) {
// write code here
unordered_map<int, int> mp;
for(int i=0; i<numbers.size(); i++){
int tmp = target - numbers[i];
if(mp.find(tmp) != mp.end()) return {mp[tmp], i+1};
else mp[numbers[i]] = i+1;
}
return {};
}
};
索引值从1开始的,且数据没有范围 不同于leecode