#K16281. Find a Pair with Given Sum
Find a Pair with Given Sum
Find a Pair with Given Sum
Given an array of integers and an integer K, determine whether there exists a pair of distinct elements in the array such that their sum is exactly K. More formally, you need to determine if there exist indices i and j (i \neq j) satisfying \(a_i + a_j = K\).
Your program should read input from stdin
and write the output to stdout
.
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 elements of the array.\ - The third line contains an integer
K
.
outputFormat
Output True
if there exists a pair of distinct elements whose sum equals K
, otherwise output False
.## sample
5
1 4 5 6 8
10
True