longest substring without repeating characters
#include <bits/stdc++.h>
using namespace std;
int main()
{
string s;
cin>>s;
int l=s.length();
map<char,int>mp;
int mx=INT_MIN;
int i=0;
int j=0;
while(j<l)
{
mp[s[j]]++;
if(int(mp.size())<j-i+1)
{
while(int(mp.size())<j-i+1)
{
mp.erase(s[i]);
i++;
}
j++;
}
else if(int(mp.size())==j-i+1)
{
mx=max(mx,j-i+1);
j++;
}
}
cout<<mx;
return 0;
}