#C1689. Two Sum Indices Problem
Two Sum Indices Problem
Two Sum Indices Problem
You are given an array of integers and a target integer. Your task is to determine whether there exist two distinct indices i and j (with i < j) in the array such that the sum of the elements at these indices is equal to the target.
If such a pair exists, print the two indices separated by a space. Otherwise, print Not Possible
.
The solution should be efficient with regard to time complexity. Formally, given an array \(A = [a_0, a_1, \dots, a_{n-1}]\) and an integer \(T\), find indices \(i, j\) such that \(i < j\) and \(a_i + a_j = T\) or report that no such indices exist.
inputFormat
The input is read from standard input and consists of three lines:
- An integer \(n\) representing the number of elements in the array.
- \(n\) space-separated integers representing the elements of the array.
- An integer representing the target sum.
outputFormat
If a valid pair is found, output the two indices (0-indexed) separated by a space. If no such pair exists, output Not Possible
.
4
2 7 11 15
9
0 1