#C12629. Two Sum Problem
Two Sum Problem
Two Sum Problem
In this problem, you are given an array of integers and a target integer. Your task is to determine if there exists a pair of distinct numbers in the array such that their sum is equal to the target. Formally, given an array ( S ) and an integer ( T ), you need to check whether there exist indices ( i ) and ( j ) with ( i \neq j ) such that
[
S_i + S_j = T
]
If such a pair exists, output True
; otherwise, output False
.
inputFormat
The input is given via standard input (stdin) and consists of two lines:
- The first line contains two space-separated integers (N) and (target), where (N) is the number of integers in the array, and (target) is the desired sum.
- The second line contains (N) space-separated integers representing the elements of the array.
outputFormat
Print a single line to standard output (stdout) containing True
if there exists a pair of distinct numbers in the array that add up to the target, otherwise print False
.## sample
4 8
1 2 3 9
False