#C1809. Two Sum Indices Problem
Two Sum Indices Problem
Two Sum Indices Problem
You are given an array of n integers and an integer target. Your task is to find the indices of the two numbers in the array such that their sum is equal to target. You may assume that each input has exactly one solution, and you may not use the same element twice.
The solution should work in an efficient manner. One recommended approach is to use a hash table to check for the complement of each array element. In mathematical terms, for each element \(a_i\) in the array, you need to find an index \(j\) such that:
[ a_i + a_j = \text{target} ]
If such indices exist, output them in the order they are found (0-indexed).
inputFormat
The first line of input contains an integer T, representing the number of test cases. For each test case, the first line contains two integers n and target separated by a space, where n is the number of elements in the array and target is the sum to find.
The second line of each test case contains n space-separated integers representing the elements of the array.
outputFormat
For each test case, output a single line containing two integers, which are the 0-indexed positions of the two numbers in the array that add up to target. The indices should be separated by a space.
## sample1
4 9
2 7 11 15
0 1
</p>