#K84292. Find Pair with Given Difference
Find Pair with Given Difference
Find Pair with Given Difference
You are given a sorted list of integers \( arr \) of length \( N \) and an integer \( K \). Your task is to determine whether there exist two distinct elements \( arr[i] \) and \( arr[j] \) such that the difference satisfies
\( arr[j] - arr[i] = K \)
If such a pair exists, print True
; otherwise, print False
.
Note: The input is provided via the standard input (stdin) and the output should be printed to the standard output (stdout).
inputFormat
The first line contains two integers \( N \) and \( K \) separated by a space.
The second line contains \( N \) sorted integers separated by spaces.
Example:
5 4 1 3 5 9 11
outputFormat
Output a single line containing either True
or False
(without quotes) indicating whether a pair with the given difference exists.
5 4
1 3 5 9 11
True