This program finds two numbers in a sorted array that add up to a given target using the two-pointer technique.
- The user inputs the number of elements in the array.
- The user inputs the elements in ascending order.
- The user enters the target sum.
- The program uses two pointers,
left
andright
, to efficiently find a pair that sums to the target.
Enter the no of element in the array: 5
Enter the elements in ascending order: 1 2 3 4 6
Enter the target no: 7
Output: 3 + 4 = 7