#K59387. Two Sum Pair Finder
Two Sum Pair Finder
Two Sum Pair Finder
You are given a list of integers and a target integer \(T\). Your task is to find two numbers from the list that add up to \(T\) and output them. If such a pair exists, output the two numbers separated by a single space in the order they are found by your algorithm; if no such pair exists, output -1
.
Note: If multiple valid pairs exist, you may output any one of them. The pair should be output in a single line, separated by a space.
For example, given the array [2, 7, 11, 15] and target \(9\), the expected output is 2 7
because \(2 + 7 = 9\).
inputFormat
The input consists of two lines.
The first line contains space-separated integers representing the list of numbers. The second line contains a single integer, the target sum T.
outputFormat
If a pair of numbers that add up to T is found, output the two numbers separated by a space in a single line. If no such pair exists, output -1.## sample
2 7 11 15
9
2 7