题目介绍
代码及其实验结果
public class Solution {
public int LengthOfLongestSubstring(string s) {
List<char> a=new List<char>();
int n = s.Length;
int max=0;
for(int i=0;i<n;i++)
{
if(a.Contains(s[i]))
{
a.RemoveRange(0,a.IndexOf(s[i])+1);
}
a.Add(s[i]);
max=a.Count>max?a.Count:max;
}
return max;
}
}