LeetCode1 Two Sum

  unordered_map<int,int>index;
  for(int i=0;i<numbers.size();++i)
    {
      auto it=index.find(target-numbers[i]);
      if(it==index.end())
	index[numbers[i]]=i;
      else
	{
	  int tmp=it->second;
	  return vector<int>{min(tmp,i)+1,max(tmp,i)+1};
	}
    }

你可能感兴趣的:(LeetCode1 Two Sum)