#C13532. Pair Sum Check
Pair Sum Check
Pair Sum Check
Given an array of integers and a target integer \(T\), determine whether there exist two distinct elements \(a_i\) and \(a_j\) in the array such that \(a_i + a_j = T\). Print True
if such a pair exists, and False
otherwise.
In other words, you need to check if there exist indices \(i \neq j\) for which \(a_i + a_j = T\). Use efficient methods to solve the problem.
inputFormat
The input is given from stdin in the following format:
- The first line contains an integer \(n\), representing the number of elements in the array.
- The second line contains \(n\) space-separated integers.
- The third line contains an integer \(T\), the target sum.
outputFormat
Output a single line to stdout containing either True
or False
indicating whether a pair with the given sum exists.
4
10 15 3 7
17
True