无重复字符的最长子串
题目如下
代码如下
public class Solution
{
public int LengthOfLongestSubstring(string s)
{
if(s==null||s=="")
return 0;
char[] a=s.ToCharArray();
int first=0;
int end=0;
int newmax=1;
int max=1;
for(end=1;end<a.Length;end++)
{
bool b=false;
for(int i=first;i<end;i++)
{
if(a[end]==a[i])
{
char ls=a[end];
if(newmax>max)
max=newmax;
first=i+1;
newmax=end-first+1;
b=true;
break;
}
}
if(b==false)
newmax++;
}
if(newmax>max)
max=newmax;
return max;
}}