题目:点击打开链接
public class Solution {
public int lengthOfLongestSubstring(String s) {
if (null == s) {
return 0;
}
int length = s.length();
if (1 >= length) {
return length;
}
int max = 0;
int count = 0;
int start = 0;
int index = 0;
for (index=0; index<length; index++) {
if (!(s.indexOf(s.charAt(index), start) == index)) {
count = index - start;
start = s.indexOf(s.charAt(index), start) + 1;
if (count > max) {
max = count;
}
}
}
count = index - start;
if (count > max) {
max = count;
}
return max;
}
}