#K8436. Pair Sum Existence
Pair Sum Existence
Pair Sum Existence
You are given an array of integers and a target integer \(T\). Your task is to determine whether there exist two distinct elements in the array such that their sum equals \(T\) (i.e. for some indices \(i\) and \(j\) with \(i < j\), \(a_i + a_j = T\)).
If such a pair exists, print True
; otherwise, print False
.
For example, if the array is [2, 7, 11, 15] and \(T=9\), since \(2+7=9\), the output should be True
.
inputFormat
The input is provided via standard input in the following format:
- The first line contains a single integer \(n\), the number of elements in the array.
- The second line contains \(n\) space-separated integers representing the array.
- The third line contains a single integer \(T\), the target sum.
outputFormat
Output a single line to standard output containing either True
or False
depending on whether there exists a pair of distinct elements whose sum equals \(T\).
4
2 7 11 15
9
True
</p>