#K93162. Find a Pair with a Given Sum

    ID: 38359 Type: Default 1000ms 256MiB

Find a Pair with a Given Sum

Find a Pair with a Given Sum

Given an array of integers and a target integer \(K\), determine whether there exists a pair of distinct elements in the array whose sum equals \(K\). The solution should achieve an expected time complexity of \(O(n)\) and space complexity of \(O(n)\).

Example 1: For the array [10, 15, 3, 7] and \(K=17\), there exists a pair (10 and 7) that sums up to 17, so the output is True.

Example 2: For the array [1, 2, 3, 4, 5] and \(K=10\), no such pair exists, so the output is False.

inputFormat

The first line contains two integers \(n\) and \(K\) where \(n\) is the number of elements in the array and \(K\) is the target sum.

The second line contains \(n\) space-separated integers representing the array elements.

outputFormat

Print a single line with either "True" if there exists a pair with sum equal to \(K\), or "False" otherwise.

## sample
4 17
10 15 3 7
True

</p>