class Solution {
public int lengthOfLongestSubstring(String s) {
HashMap<Character, Integer> window = new HashMap<Character, Integer>();
int left = 0,right=0;
int res=0;
while(right<s.length()){
char c = s.charAt(right);
right++;
window.put(c, window.getOrDefault(c, 0) + 1);
while(window.get(c)>1){
char d=s.charAt(left);
left++;
window.put(d, window.getOrDefault(d, 0)-1);
}
res=Math.max(res,right-left);
}
return res;
}
}
08-06
1116
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
02-07