#C6087. Two Sum Pair Existence
Two Sum Pair Existence
Two Sum Pair Existence
Given an array of integers and an integer \(k\), determine if there exist two distinct elements in the array such that their sum equals \(k\). In other words, find if there exist indices \(i\) and \(j\) with \(i \neq j\) for which \(A[i] + A[j] = k\). This problem is a classic exercise in using hash-based data structures for efficient lookup.
inputFormat
The first line contains two space-separated 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 \(A\). If \(n = 0\), the second line may be empty.
outputFormat
Print a single line with True
if there exist two distinct indices with \(A[i] + A[j] = k\); otherwise, print False
.
5 7
1 2 3 4 5
True