There is an unordered array, P, consisting of integers that are less than 100,000.

Check whether there is a pair of values that can sum up to the given sum, k.

 

bool test(const vector<int>& arr, int k)
{
	unordered_set<int> unord;
	for (int value : arr)
	{
		if (unord.find(value) != unord.end())
		{
			return true;
		}
		unord.insert(k - value);
	}
	return false;
}

 

+ Recent posts