【LeetCode】01.两数之和
class Solution { public: vector<int> twoSum(vector<int>& nums, int target) { vector<int> v(2,0); unordered_map<int,int> hashtable; for(int i=nums.size();i--;hashtable[nums[i]]=i){ if(hashtable.find(target-nums[i])==hashtable.end()) continue; v[0]=i; v[1]=hashtable[target-nums[i]]; return v; } return v; } };