65. Pair with Given Difference
MediumHash Set
Print YES if there are two different positions i, j with a[i] − a[j] = k, otherwise NO.
Input format
Line 1: n k Line 2: n integers
Output format
YES or NO
Example 1
Input
5 3 1 5 2 8 4
Output
YES
Example 2
Input
3 10 1 2 3
Output
NO
Constraints
2 ≤ n ≤ 10⁵ 0 ≤ k ≤ 10⁹
Read input from standard input and print the answer to standard output. Your code is judged against 7 test cases, most of them hidden.
Loading the MyLoginn IDE…