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\).
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 one single number, the size of the maximum subarray where the maximum gap does not exceed \(k\).
5 1 1 2 3 4 5
5 2 1 2 3 4 5