题解 | #最长不含重复字符的子字符串#
最长不含重复字符的子字符串
https://www.nowcoder.com/practice/48d2ff79b8564c40a50fa79f9d5fa9c7
int lengthOfLongestSubstring(char* s ) {
// write code here
int max=0;
for(int i=0;s[i]!='\0';i++){
int sum=1;
for(int j=i+1;s[j]!='\0';j++){
int si=0;
for(int k=j-1;k>=i;k--){
if(s[k]==s[j]) si=1;
}
if(si==1) break;
else sum++;
}
if(sum>max) max=sum;
}
return max;
}
时间复杂度略高,无脑办法