#K40287. Pair with Sum Problem
Pair with Sum Problem
Pair with Sum Problem
Given an array of integers and a target integer (k), determine whether there exists a pair of distinct elements in the array whose sum is exactly (k). You should output True if such a pair exists and False otherwise.
For example, consider the array [4, 7, 1, -3, 2] and (k = 5). Since the elements 4 and 1 add up to 5, the answer is True.
inputFormat
The input is given via standard input (stdin). 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 that represent the elements of the array.
outputFormat
Print a single line to standard output (stdout) containing either True or False depending on whether there exists a pair of distinct elements in the array whose sum equals (k).## sample
5 5
4 7 1 -3 2
True