Pair with Given Difference
Easyjavapythonccppjavascript
Given an array and an integer D, determine whether two elements at different positions have an absolute difference of exactly D.
Input Format
The first line contains two integers N and D. The second line contains N space-separated integers.
Output Format
Print 1 if such a pair exists, otherwise print 0.
Example 1
Input
6 78 5 20 3 2 50 80
Output
1
Explanation: 80 - 2 = 78.
- 2 <= N <= 100000
- 0 <= D <= 2000000000
- -1000000000 <= A[i] <= 1000000000