leetcode 1. 两数之和
把top 100重新刷一遍
class Solution { public: vector<int> twoSum(vector<int>& nums, int target) { unordered_map<int,int> um; for(int i=0;i<nums.size();++i) { int val=target-nums[i]; auto ite=um.find(val); if(ite!=um.end()) return vector<int>{i,ite->second}; um[nums[i]]=i; } return vector<int>{0,0}; } };