403. Two Sum II (Sorted Input)
MediumTwo Pointers
The array is sorted in non-decreasing order and has exactly one pair summing to target. Print the 1-based indices of that pair (smaller first).
Input format
Line 1: n target Line 2: n sorted integers
Output format
i j
Example 1
Input
4 9 2 7 11 15
Output
1 2
Example 2
Input
3 6 2 3 4
Output
1 3
Constraints
2 ≤ n ≤ 10⁵
Read input from standard input and print the answer to standard output. Your code is judged against 4 test cases, most of them hidden.
Loading the MyLoginn IDE…