


In the ‘i-th’ operation, you set the ‘ARR[i]-th’ bit of ‘S’ to ‘1’.
Both 'ARR' and 'S' are 1 indexed.
The first line contains a single integer ‘T’ representing the number of test cases.
The first line of each test case will contain two space-separated integers, ‘N’ and 'K', which denotes the length of the permutation 'ARR', and the required size of the group, respectively.
The second line of each test case will contain 'N' single space-separated integers, representing the permutation 'ARR'.
For each test case, print the last operation when there was a group of size 'K', else print -1.
Output for every test case will be printed in a separate line.
You don’t need to print anything; It has already been taken care of.
1 <= T <= 10
1 <= N <= 100000
1<= K <=N
1<= ARR[i] <= N
Where ‘T’ is the number of test cases, 'N' is the size of the permutation, 'K' is the size of the required group, and 'ARR[i]' is an element of the permutation.
Time limit: 1 sec
We will go through all the operations and check which old groups will merge and which new groups will get created.
We will maintain two arrays, 'left' and 'right' to store the length of groups of '1s' ending at 'i' and starting at 'i'.
To get the last index when there was a group of size 'K', we will check whether the newly merged group had size 'K'.
Element Count in Ranges
First Digit One
Minimize Maximum Adjacent Distance
Sorted Doubly Linked List to Balanced BST
Minimized Maximum of Products Distributed to Any Store