#C8295. Two Sum Indices
Two Sum Indices
Two Sum Indices
Given an array of integers and a target integer, you are required to find two distinct indices \(i\) and \(j\) (0-indexed) such that the sum of the numbers at these indices equals the target. That is, you need to find \(i\) and \(j\) satisfying:
\(a_i + a_j = \text{target}\)
If multiple solutions exist, output any one of them. If no such pair exists, output an empty list []
.
Input/Output Specifications: The input will be given through standard input (stdin) and the result must be printed on standard output (stdout) in the required format.
inputFormat
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 representing the target sum.
outputFormat
If a valid pair of indices is found, print the two indices separated by a single space. If no such pair exists, print []
(without quotes).
4
2 7 11 15
9
0 1