#K58747. Find a Pair with the Given Difference

    ID: 30711 Type: Default 1000ms 256MiB

Find a Pair with the Given Difference

Find a Pair with the Given Difference

Given an array of integers and a target integer, determine whether there exist two distinct indices \(i\) and \(j\) such that the absolute difference between the elements at these indices is equal to the target. In other words, check if there exist indices \(i, j\) (with \(i \neq j\)) such that \(|a_i - a_j| = \text{target}\).

Output True if such a pair exists, and False otherwise. Note that when the target is 0, the condition is satisfied if and only if there is at least one duplicate element in the array.

inputFormat

The input is read from standard input (stdin) and it consists of two lines:

  • The first line contains two integers \(n\) and \(\text{target}\), where \(n\) is the number of elements in the array.
  • The second line contains \(n\) space-separated integers representing the elements of the array.

outputFormat

Print a single line to standard output (stdout) containing either True or False (without quotes) indicating whether there exists a pair of distinct indices with an absolute difference equal to the target.

## sample
5 2
1 5 3 4 2
True