Given a sorted array of integers `nums` and an integer `k`, return `true` if there exist two numbers `nums[i]` and `nums[j]` such that `nums[j] - nums[i] = k` (with i != j), otherwise return `false`.
nums = sorted array of integers, k = required difference
true if a pair with difference k exists, false otherwise
Example 1:
Input:
nums = [1,3,5,6,8] k = 2
Output:
true
Explanation:
3 - 1 = 2 or 5 - 3 = 2 exists.
Example 2:
Input:
nums = [4,5,6,7,8] k = 3
Output:
true
Explanation:
7 - 4 = 3 exists.
Example 3:
Input:
nums = [1,2,4,7] k = 6
Output:
true
Explanation:
No pair has difference 6.