problem link https://www.codechef.com/LTIME81B/problems/NOTALLFL/

feb lunctime_div 2_problem 2

#include <bits/stdc++.h>

using namespace std;

int main() {

int t;

cin>>t;

while(t–)

{

unordered_map<int, int> map;

int n,k;

cin>>n>>k;

int a[n];

for(int i=0;i<n;i++)

{

cin>>a[i];

}

int index=0,count=0,max1=0;

if(k>1)

for(int i=0;i<n;)

{

map[a[i]]++;

if(map.size()!=k)

{

count++;

i++;

}

else

{

// cout<<map.size()<<" “<<i;

max1=max(max1,count);

map.clear();

count=0;

}

}

max1=max(max1,count);

cout<<max1<<”\n";

}

return 0;

}