#include <iostream>
using namespace std;
#include<vector>
#include <bits/stdc++.h>
int main() {
// your code goes here
vector<int>arr={3,2,4,5,2,6,7,8,9,10};
int n=arr.size();
int i=0,j=0;
int current_length=0,max_length=0;
unordered_map<int,int>mp;
int d=0;
int k=n/2;
while(i<n && j<n)
{
if(mp.find(arr[j])==mp.end())
{
mp[arr[j]]=j;
current_length=(j-i+1);
max_length=max(current_length,max_length);
}
else
{
int previous_occurence=mp[arr[j]];
while(i<=previous_occurence)
{
mp.erase(arr[i]);
i++;
}
i=previous_occurence+1;
mp[arr[j]]=j;
}
j++;
}
cout<<max_length;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwojaW5jbHVkZTx2ZWN0b3I+CiNpbmNsdWRlIDxiaXRzL3N0ZGMrKy5oPgoKaW50IG1haW4oKSB7CgkvLyB5b3VyIGNvZGUgZ29lcyBoZXJlCgl2ZWN0b3I8aW50PmFycj17MywyLDQsNSwyLDYsNyw4LDksMTB9OwoJaW50IG49YXJyLnNpemUoKTsKCQoJaW50IGk9MCxqPTA7CglpbnQgY3VycmVudF9sZW5ndGg9MCxtYXhfbGVuZ3RoPTA7Cgl1bm9yZGVyZWRfbWFwPGludCxpbnQ+bXA7CglpbnQgZD0wOwoJaW50IGs9bi8yOwoJd2hpbGUoaTxuICYmIGo8bikKCSB7CgkgCgkgICAgaWYobXAuZmluZChhcnJbal0pPT1tcC5lbmQoKSkKCSAgICAgewoJICAgICAJbXBbYXJyW2pdXT1qOwoJICAgICAJY3VycmVudF9sZW5ndGg9KGotaSsxKTsKCSAgICAgCW1heF9sZW5ndGg9bWF4KGN1cnJlbnRfbGVuZ3RoLG1heF9sZW5ndGgpOwoJICAgICAJCgkgICAgIH0KCSAgICAgZWxzZQoJICAgICAgewoJICAgICAgCWludCBwcmV2aW91c19vY2N1cmVuY2U9bXBbYXJyW2pdXTsKCSAgICAgIAl3aGlsZShpPD1wcmV2aW91c19vY2N1cmVuY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