#K62537. Pair Sum Finder
Pair Sum Finder
Pair Sum Finder
You are given an integer n representing the number of elements in an array, followed by n space‐separated integers, and an integer target. Your task is to determine whether there exist two distinct indices i and j such that:
\[ arr[i] + arr[j] = target \]
If such a pair exists, output 1
; otherwise, output 0
.
Note that the pair must consist of two different elements.
inputFormat
The input is given via standard input and consists of three lines:
- The first line contains an integer
n
, the number of elements in the array. - The second line contains
n
space-separated integers representing the array. - The third line contains an integer
target
, the target sum.
outputFormat
Output a single integer to standard output: 1
if there exist two distinct indices i and j such that arr[i] + arr[j] = target
, otherwise 0
.
5
1 2 3 4 5
7
1
</p>