滑动窗口,前后指针
class Solution {
public int lengthOfLongestSubstring(String s) {
int p = 0, l = 0, max = 0;
for (int i = 0; i < s.length(); i++) {
for (int j = p; j < l; j++) {
if (s.charAt(j) == s.charAt(i)) p = j + 1;
}
l++;
max = Math.max(max, l - p);
}
return max;
}
}