You are given an array A of N integers and an integer B.
You have to find the longest subarray of A such that the difference between the maximum and the minimum element of that subarray is strictly less than B.
The first argument given is an Array A, having N integers. The second argument is an integer B.
Return an integer X, i.e size of the longest subarray
1 <= N <= 1e5 1 <= A[i] <= 1e6 1 <= B <= 1e6
Input: A = [1, 2, 4] B = 2 Output: 2 Explanation: only subarray which has a difference of maximum and minimum element strictly less than 2 is: [1, 2]
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 doubt? Checkout Sample Codes for more details.