#C1372. Two Sum Problem
Two Sum Problem
Two Sum Problem
You are given an array of integers and a target integer \(T\). Your task is to find two distinct indices \(i\) and \(j\) in the array such that:
\(a_i + a_j = T\)
If such a pair exists, output the two indices in increasing order separated by a space. If no such pair exists, output an empty line.
It is guaranteed that each input will have at most one solution. You may not use the same element twice.
inputFormat
The input is read from standard input (stdin) and has the following format:
- The first line contains an integer \(n\), the number of elements in the array.
- The second line contains \(n\) integers separated by spaces, representing the elements of the array.
- The third line contains an integer \(T\), the target sum.
outputFormat
Print two integers representing the indices of the two numbers that add up to \(T\) separated by a space. If no such pair exists, print an empty line.
## sample4
2 7 11 15
9
0 1
</p>