#K91837. Find Pair With Sum
Find Pair With Sum
Find Pair With Sum
You are given an array of integers and a target value \(T\). Your task is to find the indices of the two numbers in the array whose sum is equal to \(T\). It is guaranteed that exactly one solution exists.
Note: The indices returned should follow the order in which the pair is found; assume that each input has exactly one valid solution.
Example: For the input array [2, 7, 11, 15] and target \(9\), the correct output is 0 1
because \(2 + 7 = 9\).
inputFormat
The input is given via stdin and has the following format:
- The first line contains an integer \(n\), representing the number of elements in the array.
- The second line contains \(n\) space-separated integers representing the array elements.
- The third line contains an integer \(T\), the target sum.
outputFormat
Output two space-separated integers on a single line via stdout which represent the indices of the two numbers that add up to the target.
## sample4
2 7 11 15
9
0 1