Mediumhasharrays
Two Sum Indices
Time limit 2 s · Memory 64 MBAcceptance: 100.0%Solved by: 1
Statement
The first line contains n, the second line contains n integers, the third line contains target. Find the indices (1-based, i < j) of two elements whose sum equals target. Scanning left to right, print the first pair found: the smallest j, and for that j the smallest i. If no such pair exists, print -1.
Examples
Example 1
Input
4 2 7 11 15 9
Output
1 2
Example 2
Input
5 3 2 4 1 5 6
Output
2 3
Constraints
- 2 ≤ n ≤ 10^5
- -10^9 ≤ a_i, target ≤ 10^9