#C3228. Pair With Sum
Pair With Sum
Pair With Sum
You are given an array of integers and a target sum \( S \). Your task is to determine whether there exist two distinct elements in the array whose sum equals \( S \). In other words, find if there exist indices \( i \) and \( j \) (with \( i \neq j \)) such that:
\( arr[i] + arr[j] = S \)
If such a pair exists, output True
. Otherwise, output False
.
Note: The input is read from stdin and the output should be written to stdout.
inputFormat
The first line of input 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 the integer \( S \), the target sum.
outputFormat
Output a single line containing True
if there exists a pair of distinct elements that add up to \( S \); otherwise, output False
.
6
1 4 45 6 10 -8
16
True