#C1371. Pair with Exact Difference
Pair with Exact Difference
Pair with Exact Difference
Given an array of integers and a target integer \(x\), determine whether there exists at least one pair of distinct elements in the array such that the absolute difference between them equals \(x\). Formally, you need to check if there exist indices \(i\) and \(j\) (with \(i \neq j\)) satisfying \(|a_i - a_j| = x\).
For example, given the array [1, 5, 3, 4] with \(x = 2\), since \(|1 - 3| = 2\) (and also \(|3 - 5| = 2\)), the correct answer is "Yes". Otherwise, output "No".
inputFormat
The first line of input contains two integers (n) and (x), where (n) is the number of elements in the array and (x) is the target difference. The second line contains (n) space-separated integers representing the array elements.
outputFormat
Output a single line with the string "Yes" if there exists at least one pair of distinct elements in the array with absolute difference equal to (x), otherwise output "No".## sample
4 2
1 5 3 4
Yes
</p>