class Solution {
public:
/**
*
* @param numbers int整型vector
* @param target int整型
* @return int整型vector
*/
vector<int> twoSum(vector<int>& numbers, int target) {
int size = numbers.size();
vector<int> ans;
unordered_map<int, int > map;
unordered_map<int, int >::iterator it;
for(int i=0; i<size; i++){
map.insert(make_pair(numbers[i], i));
}
for(int i=0; i<size; i++){
if((it = map.find(target-numbers[i]))!=map.end()&&it->second!=i){
int min = it->second>i ? i: it->second;
int max = it->second<i ? i: it->second;
ans.insert(ans.begin(), min+1);
ans.insert(ans.begin()+1, max+1);
break;
}
}
return ans;
}
};