给定一个长度为 n 的整数序列,请找出最长的不包含重复的数的连续区间,输出它的长度。
样例:
5
1 2 2 3 5
#includeusing namespace std; const int N=100010; int q[N],w[N],n; int main() { cin>>n; int res=0; for(int i=0,j=0; i >q[i]; w[q[i]]++; while(j1) w[q[j++]]--; res=max(i-j+1,res); } cout< 样例输出:
3



