#K54802. Find Two Sum Indices
Find Two Sum Indices
Find Two Sum Indices
You are given a list of integers and a target integer. Your task is to find the indices of the two numbers that add up to the target sum. It is guaranteed that exactly one solution exists and you cannot use the same element twice.
The solution should run efficiently even if the list contains a large number of elements. Use appropriate data structures to optimize the process of finding the complement of each number.
Formally, given a list of integers \( A = [a_0, a_1, \ldots, a_{n-1}] \) and a target integer \( T \), find indices \( i \) and \( j \) (with \( i \neq j \)) such that:
[ a_i + a_j = T ]
Indices are 0-indexed.
inputFormat
The input is given from standard input and consists of three lines:
- The first line contains an integer \( n \) which is the number of elements in the list.
- The second line contains \( n \) space-separated integers.
- The third line contains a single integer, the target sum \( T \).
outputFormat
Output to standard output a single line with two space-separated integers representing the indices of the two numbers whose sum equals \( T \).
## sample5
2 7 11 15 1
9
0 1