Given a sorted array of integers and a target value, return true if there exists a pair of distinct elements whose sum equals the target. This uses the two-pointer approach to find a pair in O(n) time.
nums = array of integers, target = required sum
true if a valid pair exists, false otherwise
Example 1:
Input:
nums = [1,2,3,4] target = 5
Output:
true
Explanation:
The pair (1, 4) sums to 5.