Pair with exact difference
Your task
Given a sorted array of distinct integers nums and a positive integer d, return True if some pair of elements differs by exactly d, and False otherwise. Use two pointers that both move forward (a fast and a slow index) for an O(n) scan, no nested loops, no hash set. Example: nums = [1, 3, 6, 10], d = 4 gives True because 10 - 6 = 4.
Examples
has_pair_with_gap(nums: list[int], d: int) -> boolExample 1
Input
has_pair_with_gap([1, 3, 6, 10], 4)Output
True