#K69512. Two Sum Problem
Two Sum Problem
Two Sum Problem
Given an array of integers and a target integer \(T\), find two distinct elements in the array such that their sum equals \(T\). If such a pair exists, output the indices (1-indexed) of these two elements; otherwise, output -1.
Note: Each array element is used at most once, and the pair should be the first valid pair found by scanning the array from left to right.
inputFormat
The input is given via standard input (stdin). The first line contains two integers (n) (the number of elements) and (T) (the target sum). The second line contains (n) space-separated integers representing the array.
outputFormat
Output to standard output (stdout). If a valid pair is found, output two space-separated integers representing the 1-indexed positions of the two elements. If no such pair exists, output -1.## sample
5 9
2 7 11 15 1
1 2