给定一个字符串,请你找出其中不含有重复字符的 最长子串 的长度。

class Solution {
public:
int lengthOfLongestSubstring(string s)
{
int num=0;
int N=s.size();

string check;
std::cout<<"N="<<N;
int count=0;
int max_num=0;
int j=0;
for (int i=1;i<N-1;i++)
{
if(s[0]==s[1])
{
j=1;
count=0;
}
else
{
count=1+count;
}

for(int k=j;k<i+1;k++)
{
if(s[i]==s[k])
{
count=0;
j=i ;
}
else
{
count=1+count;
if(max_num<count)
{max_num=count;}
}
}
}
return 0 ;
}

};

原文地址:https://www.cnblogs.com/shuimuqingyang/p/11416647.html