#K57877. Find Pair with Specific Difference

    ID: 30518 Type: Default 1000ms 256MiB

Find Pair with Specific Difference

Find Pair with Specific Difference

Given an array of integers and a target integer \(T\), determine whether there exist two distinct indices \(i\) and \(j\) such that either \(nums[i]-nums[j]=T\) or \(nums[j]-nums[i]=T\). Note that when \(T = 0\), the pair must consist of two identical numbers occurring at different positions.

The program should read input from standard input and output the result to standard output as either "True" or "False".

inputFormat

The input consists of three lines:

  1. The first line contains an integer \(n\) representing the number of elements in the array.
  2. The second line contains \(n\) space-separated integers representing the array elements. If \(n = 0\), this line may be empty.
  3. The third line contains an integer \(T\), the target difference.

outputFormat

Output a single line to standard output: "True" if such a pair exists, and "False" otherwise.

## sample
4
1 5 9 13
4
True