Unique Snowflakes UVA - 11572
Problem description :

Input and output description :

** thinking :** Sliding window algorithm
set up l,r Left and right cursors ,
As long as there is no repetition r++;
I know I'm going to have a repeat , Jump out of inner circle , Update value , And remove it a[l],l++;

ac code:
#include<bits/stdc++.h> using namespace std; typedef long long ll; int a[
1000002]; int n; int main(){ int t; scanf("%d",&t); while(t--){ scanf("%d",&n);
for(int i=1;i<=n;i++){ scanf("%d",&a[i]); } ll maxlen=0; ll l=1,r=1; set<int> s;
while(r<=n){ while(r<=n&&!s.count(a[r]))s.insert(a[r++]); maxlen=max(maxlen,r-l)
; s.erase(a[l++]); } printf("%lld\n",maxlen); } return 0; }

Technology
©2019-2020 Toolsou All rights reserved,
java Four functional interfaces ( a key , simple ) It's unexpected Python Cherry tree (turtle The gorgeous style of Library ) Browser kernel ( understand )HashMap Explain in detail Some East 14 Pay change 16 salary , Sincerity or routine ?html Writing about cherry trees , Writing about cherry trees