给定一个字符串,请你找出其中不含有重复字符的 最长子串 的长度。
class Solution {
public int lengthOfLongestSubstring(String s) {
if(s==null){
return 0;
}
String maxstr=s;
Map m1=new HashMap();
for(int i=0;i<s.length();i++){
int num=0;
for(int j=i+1;j<s.length()-i;j++){
if(s.charAt(i)==s.charAt(j)){
num++;
maxstr=s.substring(i,j);
m1.put(maxstr,num);
break;
}
}
}
return m1.GetMaxValue();
}
}