class Solution {
public:
int res=0;
int lengthOfLongestSubstring(string s) {
int n=s.size ();
if(!n) return 0;
bool st[128]={false};
for(int j=0,i=0;j<n;j++)
{
while(j&&st[s[j]]==true)//该字符是重复字符
st[s[i++]]=false;
st[s[j]]=true;
res=max(res,j-i);
}
return res+1;
}
};
标签:子串,字符,int,最长,重复,LeetCode
From: https://www.cnblogs.com/tangxibomb/p/17607665.html