
‘N’ = '6'
'K' = '3'
The next line contains 'Ai', the colour of the 'ith' ball from the left,
1 2 1 3 2 3
Assuming 0-based indexing, If Ninja gets the balls from index 2 to 4, i.e., the contiguous set {1,3,2} he will have 3 different coloured balls, which is the maximum possible answer.
He can also get the balls from index 1 to 3, i.e., the set {2,1,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 'K', denoting the total number of balls and the number of balls Ninja can take, respectively.
The second line of each test case contains 'N' space-separated integers 'Ai', where the 'ith' element denotes the colour of the ball 'i'.
For each test case, return the maximum possible number of distinct colours in balls Ninja can pick.
You don't need to print anything. It has already been taken care of. Just implement the given function.
1 <= T <= 10
1 <= K <= N <= 10^5
1 <= Ai <= 10^9 (0 <= i <= N-1)
The sum of 'N' overall 'T' does not exceed 10^5.
Time Limit: 1 sec
Algorithm: