#C13177. Find Target Sum Pairs

    ID: 42686 Type: Default 1000ms 256MiB

Find Target Sum Pairs

Find Target Sum Pairs

Given an array of unique integers and a target value \(T\), your task is to identify all the pairs of numbers whose sum equals \(T\). Each pair must be printed on a separate line in the format "a b", where \(a\) and \(b\) are the two numbers making up the pair.

Note that a number is paired with an earlier encountered number if they sum to \(T\). If no such pairs exist, simply print an empty output (i.e. no output).

Example 1:
Input: [2, 4, 3, 5, 7, 8, 1], T = 10
Output:
3 7
2 8

Example 2:
Input: [1, 2, 3, 4, 5], T = 9
Output:
4 5

inputFormat

The first line contains an integer \(n\) representing the number of elements in the array. The second line contains \(n\) space-separated integers which are the elements of the array. The third line contains an integer \(T\), the target sum value.

outputFormat

Print each pair of numbers that sums to \(T\) on a separate line in the format "a b". The order of pairs should be the same as they are found in the array (i.e. when the complement has been encountered). If no such pair exists, output nothing.

## sample
7
2 4 3 5 7 8 1
10
3 7

2 8

</p>