No Name Problem
You are given an array \(A\) of size \(n\) and a number \(k\). You are tasked to find the size of the maximum subarray where the difference between the minimum element in the subarray and the maximum element of the subarray does not exceed \(k\).
That is \(Max(A[i..j]) - Min(A[i..j]) <= k\).
Input Specification
The first line of the input consists of two integers, \(1 \le n \le 10^5\) and \(0 \le k \le 2\times 10^9\).
The next line of the input consists of the elements of the array where \(-10^9 \le A_i \le 10^9\)
Output Specification
Output one single number, the size of the maximum subarray where the maximum gap does not exceed \(k\).
Sample Input
5 1
1 2 3 4 5
Sample Output
2
Sample Input
5 2
1 2 3 4 5
Sample Output
3
Comments
ansewered