https://leetcodechina.com/problems/two-sum/description/
map
class Solution {
public:
vector<int> twoSum(vector<int>& nums, int target) {
vector<int> ans;
map<int, int> vis;
for (int i = 0; i < nums.size(); ++i){
if (!vis.count(nums[i])) vis[target - nums[i]] = i;
else ans.push_back(vis[nums[i]]),ans.push_back(i);
}
return ans;
}
};