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; }

©2019-2020 Toolsou All rights reserved,
Huawei 2021 session Hardware Engineer Logical post (FPGA) Super detailed surface !!!Vue-element-admin upgrade ui edition virtual machine VMware Download and install the most detailed tutorial !C++ Move constructor and copy constructor sound of dripping water java Backstage interview pygame Realize full screen mode and adjustable window size mysql Database setting character set configuration modification my.ini file (windows)30 What's the experience of being a junior programmer at the age of 20 C++ Multithreading programming ( Summary of common functions and parameters )python_ cherry tree