#K73362. Two-Sum Pair Check
Two-Sum Pair Check
Two-Sum Pair Check
You are given an integer \(n\) representing the number of elements, a list of \(n\) integers, and an integer \(\tau\) representing the target sum. Your task is to determine whether there exist two distinct integers in the list whose sum equals \(\tau\). For example, if the input list is [2, 7, 11, 15, 1] and \(\tau = 9\), the answer is True
because 2 and 7 add up to 9.
The solution should read input from standard input (stdin) and output the result to standard output (stdout) as either True
or False
.
Note: In the LaTeX format, the target is represented as \(\tau\). Use efficient methods such as a hash set to achieve optimal performance.
inputFormat
The input is read from stdin and contains three parts:
- An integer \(n\) on the first line representing the number of elements in the list.
- A second line containing \(n\) space-separated integers.
- A third line containing an integer \(\tau\) which is the target sum.
If \(n = 0\), the second line may be empty.
outputFormat
The output is a single line written to stdout. It should be True
if there exist two distinct integers in the list that add up to \(\tau\), and False
otherwise.
5
2 7 11 15 1
9
True