Skip to content
CampusEduX

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.

Related Problems

  • Frequency Map
    Easy · java, python, c, cpp, javascript
    Solve Problem
  • Find Duplicate Values
    Easy · java, python, c, cpp, javascript
    Solve Problem
  • Common Elements in Three Arrays
    Easy · java, python, c, cpp, javascript
    Solve Problem

Input (stdin)

Output

Run your code to see output here...