#C6780. Two Sum Problem
Two Sum Problem
Two Sum Problem
You are given an array of integers and a target value \(T\). Your task is to find two distinct indices \(i\) and \(j\) (0-indexed) such that:
\(arr[i] + arr[j] = T\)
It is guaranteed that each test case has at most one solution. If such a pair exists, output the indices separated by a space; otherwise, output -1.
inputFormat
The input is given via standard input (stdin) and consists of three parts:
- The first line contains an integer \(n\), the number of elements in the array.
- The second line contains \(n\) space-separated integers representing the array \(arr\).
- The third line contains an integer \(T\), the target sum.
outputFormat
Output a single line via standard output (stdout): if a valid pair exists, print the two indices (0-indexed) separated by a space. If no such pair exists, print -1.
## sample4
2 7 11 15
9
0 1