class Solution {
public:
vector<int> twoSum(vector<int>& nums, int target) {
// 将所有数都放入hash表
// 扫描到第Si个数时, 查看target-Si是否在hash表中 O(n)
unordered_map<int, int> heap;
for(int i = 0; i < nums.size(); i++){
int query = target - nums[i];
if(heap.count(query)) return {heap[query], i};
heap[nums[i]] = i;
}
return {};
}
};