#K10901. Two Sum Indices
Two Sum Indices
Two Sum Indices
You are given an array of integers and a target sum \( S \). Your task is to find two distinct indices \( i \) and \( j \) in the array (using 1-indexing) such that:
\( arr[i] + arr[j] = S \)
If a valid pair exists, output the two indices (with \( i < j \)). If no such pair exists, output -1.
Note: The array is 1-indexed.
inputFormat
The input consists of two lines. The first line contains two integers: \( n \), the number of elements in the array, and \( S \), the target sum. The second line contains \( n \) space-separated integers representing the array elements.
outputFormat
If a valid pair is found, print the two 1-indexed positions separated by a space. If no such pair exists, print -1.
## sample5 9
2 7 11 15 1
1 2
</p>