//唯一的雪花 uva 11572 《紫书》p239-241 //1 #include<cstdio> #include<set> #include<algorithm> using namespace std; #define N 1000050 int a[N]; int main(){ int t,n; scanf("%d",&t); while(t--){ scanf("%d",&n); for(int i=0;i<n;i++) scanf("%d",a+i); set<int>s; int l=0,r=0,ans=0; while(r<n){ while(r<n&&!s.count(a[r])) s.insert(a[r++]); ans=max(ans,r-l); s.erase(a[l++]); } printf("%d ",ans); } return 0; } //2 #include<cstdio> #include<map> using namespace std; #define N 1000100 int a[N],last[N]; map<int,int>cur; int main(){ int t,n; scanf("%d",&t); while(t--){ scanf("%d",&n); cur.clear(); for(int i=0;i<n;i++){ scanf("%d",a+i); if(!cur.count(a[i])) last[i]=-1; else last[i]=cur[a[i]]; cur[a[i]]=i; } int l=0,r=0,ans=0; while(r<n){ while(r<n&&last[r]<l) r++; ans=max(ans,r-l); l++; } printf("%d ",ans); } return 0; }