#C11740. Find Pair With Target Sum
Find Pair With Target Sum
Find Pair With Target Sum
Given an array of integers \(a_1,a_2,\ldots,a_n\) and a target sum \(T\), find any two numbers in the array whose sum equals \(T\). If such a pair exists, output the two numbers in the order they are found (from left to right). Otherwise, output None
.
Note: The pair should be determined by scanning the array from the beginning and returning the first valid pair encountered.
inputFormat
The input consists of two lines:
- The first line contains two integers \(n\) and \(T\), where \(n\) is the number of elements in the array and \(T\) is the target sum.
- The second line contains \(n\) space-separated integers representing the array elements.
outputFormat
If a valid pair is found, output the two integers separated by a space. If no such pair exists, output None
.
6 16
1 4 45 6 10 -8
6 10