#K36222. Find Pair with Sum
Find Pair with Sum
Find Pair with Sum
You are given an array of integers and a target integer \(T\). Your task is to determine whether there exist two distinct indices \(i\) and \(j\) in the array such that the sum of \(a_i\) and \(a_j\) is equal to \(T\), i.e., \(a_i + a_j = T\).
The input is read from standard input and the output must be printed to standard output.
If such a pair exists, output True
; otherwise, output False
.
inputFormat
The input consists of three lines:
- The first line contains an integer \(n\) representing the number of elements in the array.
- The second line contains \(n\) space-separated integers representing the array elements.
- The third line contains an integer \(T\) representing the target sum.
outputFormat
Output a single line with True
if there exists a pair of distinct indices with the required sum, or False
if no such pair exists.
4
2 7 11 15
9
True