#K37052. Two Sum Indices
Two Sum Indices
Two Sum Indices
You are given a list of integers and a target integer T. Your task is to find two distinct indices i and j (with i < j) such that the sum of the numbers at these indices equals the target, i.e. \(a_i + a_j = T\).
It is guaranteed that each input has exactly one solution. In other words, there exists a unique pair \((i, j)\) such that the condition holds. You are not allowed to use the same element twice.
Note: The indices must be output in increasing order.
inputFormat
The input is given via stdin and consists of two lines. The first line contains two integers: n
(the number of elements in the list) and target
, separated by a space. The second line contains n
integers separated by spaces representing the elements of the list.
For example:
5 9 2 7 11 15 1
outputFormat
Output to stdout two integers separated by a space, corresponding to the indices of the two numbers that add up to the target. The first index should be less than the second index.
For example:
0 1## sample
5 9
2 7 11 15 1
0 1