#K6676. Pair Sum Checker
Pair Sum Checker
Pair Sum Checker
You are given an array of n integers and a target integer t.
Your task is to determine whether there exist two distinct elements in the array whose sum equals the target. Formally, you need to check if there exist indices i and j with i \neq j such that \[ a_i + a_j = t \]
If such a pair exists, output True
; otherwise, output False
.
inputFormat
The input is given via stdin and has the following format:
n a1 a2 a3 ... an t
Where:
- n is an integer representing the number of elements in the array.
- a1, a2, ..., an are the space-separated integers of the array. If n is 0, the array line will be empty.
- t is the target sum.
outputFormat
Output a single line to stdout containing either True
or False
, indicating whether there exists a pair of distinct elements that sums exactly to the target value.
5
1 2 3 4 5
8
True