#C4089. Pair with Given Difference

    ID: 47588 Type: Default 1000ms 256MiB

Pair with Given Difference

Pair with Given Difference

You are given an array of integers and an integer k. Your task is to determine whether there exists a pair of distinct elements in the array such that their difference equals k. In mathematical terms, you need to check if there exists two elements a and b in the array such that:

\(|a - b| = k\)

If such a pair exists, print Yes; otherwise, print No.

Note: The pair can be found in any order (i.e., either a - b = k or b - a = k will satisfy the condition).

inputFormat

The input will be read from standard input (stdin). The first line contains a single integer T representing the number of test cases. Each test case consists of two lines:

  1. The first line contains two space-separated integers n and k, where n is the number of elements in the array and k is the target difference.
  2. The second line contains n space-separated integers representing the elements of the array.

It is guaranteed that 0 ≤ n ≤ 105 and the array elements are in the range of the 32-bit integer.

outputFormat

For each test case, output a single line to standard output (stdout) containing either Yes or No depending on whether a pair with the given difference exists.

## sample
3
5 2
1 5 3 4 2
4 6
1 2 3 4
3 2
1 3 5
Yes

No Yes

</p>