#C3342. Find Pair with Given Difference

    ID: 46759 Type: Default 1000ms 256MiB

Find Pair with Given Difference

Find Pair with Given Difference

Given an array of integers and an integer (k), determine whether there exists a pair of distinct elements (a_i) and (a_j) in the array such that their absolute difference is exactly (k), i.e. (|a_i - a_j| = k).

For example, if the array is [1, 5, 3, 4, 2] with (k = 3), the answer is True because (|1 - 4| = 3). If no such pair exists, output False.

inputFormat

The first line contains an integer (n), the number of elements in the array.\nThe second line contains (n) space-separated integers representing the array.\nThe third line contains an integer (k), the target difference.

outputFormat

Output a single line containing "True" if there exists a pair of distinct integers such that their absolute difference is equal to (k), otherwise output "False".## sample

5
1 5 3 4 2
3
True