Loading repovive.com/problems/classics/27
Given a sorted array of n integers in non-decreasing order and a target sum S, find two elements at different positions that add up to S.
Output the two values in increasing order. If no such pair exists, output −1.
If multiple valid pairs exist, output the one with the smallest first value.
5 9 1 2 4 5 7
For this input, the required output is 2 7.
2 7
4 10 1 2 3 4
For this input, the required output is -1.
-1
6 0 -5 -3 -1 1 3 5
For this input, the required output is -5 5.
-5 5