class Solution {
public:
int longestSubstringWithoutDuplication(string s) {
int len=0,n=s.size(),cnt[30];
memset(cnt,0,sizeof cnt);
for (int i = 0,j = 0; j < n; j ++ )
{
cnt[s[j]-'a']++;
while(i<j&&cnt[s[j]-'a']>1)
{
cnt[s[i]-'a']--;
i++;
}
len=max(len,j-i+1);
}
return len;
}
};
标签:字符,cnt,int,len,++,字符串,最长
From: https://www.cnblogs.com/tangxibomb/p/17358761.html