#C12326. Find Two Sum
Find Two Sum
Find Two Sum
You are given an integer n and an array of n integers, followed by a target integer T. Your task is to find two distinct elements, a and b, in the array such that their sum equals T.
This can be mathematically stated as finding two numbers such that
\[
a+b=T
\]
where \(a,b\in A\) and \(a\neq b\). If a valid pair exists, output the two numbers (in the order as determined by the algorithm); otherwise, output None
.
The input will be given via stdin and the output should be printed to stdout.
inputFormat
The input is read from standard input (stdin) and is formatted as follows:
- The first line contains an integer n, representing the number of elements in the array.
- The second line contains n space-separated integers.
- The third line contains the target integer T.
outputFormat
If a pair of numbers whose sum is equal to T exists, print the two integers separated by a space. If such a pair does not exist, print None
.
4
2 7 11 15
9
7 2
</p>