Letβs say we have an array {1, 2, 3, 6, 2, 3, 4, 7, 8} and integer K = 3.
The given array of length 9 can be split into 3 subsets {1, 2, 3}, {2, 3, 4} and {6, 7, 8} such that each subset consists of 3 consecutive elements.
The very first line of input contains an integer βTβ denoting the number of test cases.
The first line of every test case contains two integers βNβ and βKβ where βNβ denotes the number of elements present in the array and βKβ denotes the size of each subset in which the array has to be divided so that it contains βKβ consecutive elements.
The second line of every test case contains βNβ space-separated integers denoting the elements present in the array.
For each test case, print a single line containing "True" or "False" depending on whether the array can be divided into βKβ sized subsets with 'K' consecutive elements.
The output for each test case is printed on a separate line.
You do not need to print anything, it has already been taken care of. Just implement the given function.
1 <= T <= 10
1 <= K <= N <= 5 * 10 ^ 4
1 <= ARR[i] <= 10 ^ 9
Where βARR[i]β represents the array element.
Time Limit: 1 sec
Approach:
Algorithm: