Problem Description
Given an array 'A' of sorted integers and another non-negative integer B, find if there exist 2 indices i and j such that A[i] - A[j] = k, i != j.
Return 0 / 1 ( 0 for false, 1 for true ) for this problem
Try doing this in less than linear space complexity.
Problem Constraints
1 <= |A| <= 106
0 <= B <= 109
Input Format
The first argument is an integer array A.
The second argument is an integer B.
Output Format
Return an integer, 0 / 1 ( 0 for false, 1 for true ) for this problem
Example Input
Example Output
Example Explanation
For the given,
A : [1 3 5]
B : 4
Output : YES
as 5 - 1 = 4
NOTE: You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified.
Still have a question? Checkout Sample Codes for more details.