class Solution {
public:
vector<int> twoSum(vector<int>& nums, int target) {
unordered_map<int, int> map;
for (int i = 0; i < nums.size(); i ++) {
auto temp = map.find(target - nums[i]);
if (temp != map.end()) return {temp->second, i};
map.insert({nums[i], i});
}
return {};
}
};
标签:map,target,temp,nums,int,LeetCode,两数
From: https://www.cnblogs.com/hjy94wo/p/16658980.html