class Solution {
public:
int a[26];
int longestSubstringWithoutDuplication(string s) {
int res=0;
for(int i=0,j=0;i<s.size();i++)
{
a[s[i]-'a']++;
while(a[s[i]-'a']>1)
{
a[s[j]-'a']--;
j++;
}
res=max(res,i-j+1);
}
return res;
}
};