class Solution {
public:
int lengthOfLongestSubstring(string s) {
if(s=="") return 0;
int a[128]={0},i,start=0,l=1;
for(i=0;i<size(s);i++)
{
if(a[s[i]]!=0||i>0&&s[i]==s[0]) start=a[s[i]]>=start?a[s[i]]+1:start;
l=max(l,i-start+1);
a[s[i]]=i;
}
return l;
}
};
```![在这里插入图片描述](https://img-blog.csdnimg.cn/2020031623254955.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3lranNf,size_16,color_FFFFFF,t_70)
无重复字符的最长字符串
最新推荐文章于 2023-02-11 16:57:53 发布