#include <unordered_map>
#include <vector>
#include <iostream>
using namespace std;
class Solution
{
public:
	vector<int> twoSum(vector<int> &nums, int target)
	{
		std::unordered_map<int, int> hset;
		vector<int> r;
		for (int i = 0; i < nums.size(); ++i)
		{
			int c = target - nums[i];
			auto iter = hset.find(c);
			if (iter != hset.end() && iter->second != i)
			{
				r.push_back(i);
				r.push_back(iter->second);
				return r;
			}
			hset.insert(std::make_pair(nums[i], i));
		}
		return r;
	}
};

int main()
{
	Solution test;
	int arr[] = {3, 2, 4};
	vector<int> ret;
	vector<int> vec(arr, arr + 4);
	ret = test.twoSum(vec, 6);
	for (auto i = ret.begin(); i != ret.end(); i++)
	{
		cout << *i << ' ';
	}
	return 0;
}
