Untitled

mail@pastecode.io avatar
unknown
plain_text
18 days ago
291 B
1
Indexable
Never
int n;
    cin>>n;
    vi v(n);inputv(v)
int M[n+2];
for(int i=0;i<n+2;i++){M[i]=0;}
for(int i=0;i<n;i++){
M[v[i]]++;
}

if(M[0]==0){cout<<0<<endl;}

else{
    bool rr=false;

for(int i=0;i<n+2;i++){
if(M[i]==1){if(rr){cout<<i<<endl;break;}rr=true;}


if(M[i]==0){cout<<i<<endl;break;}

}

}
Leave a Comment