
‘N’ = '7'
'X' = 5
The following line contains 'Ai', the 'ith' element from the left.
3 4 8 5 9 6 1
Assuming 0-based indexing, Ninja can perform the operations on 'i'=2, 'A[i]' = 8 once and 'i'=3, 'A[i]' = 5 four times to obtain [3 4 9 9 9 6 1].
Thus, the longest subarray with equal elements that can be obtained is [9, 9, 9] i.e. of length 3.
The first line contains an integer 'T', which denotes the number of test cases to be run. Then the test cases follow.
The first line of each test case contains two space-separated integers 'N' and 'X', denoting the total number of elements and the maximum number of allowed operations respectively.
The second line of each test case contains 'N' space-separated integers, the elements of the array 'A'.
For each test case, return the length of the longest subarray with the same elements that could be obtained after performing the operations.
You don’t need to print anything. It has already been taken care of. Just implement the given function.
1 <= T <= 10
1 <= N <= 10^5
0 <= X < 2^31
1 <= Ai <= 10^9 (0 <= i <= N-1)
The sum of 'N' overall 'T' does not exceed 10^5.
Time Limit: 1 sec
Mirrored Difference Update
K-Balanced Linked List
Sorted Doubly Linked List to Balanced BST
Longest Unique Subarray
Minimized Maximum of Products Distributed to Any Store