https://leetcode-cn.com/problems/longest-substring-without-repeating-characters/
class Solution {
public int lengthOfLongestSubstring(String s) {
Map<Character,Integer> crrent = new HashMap(s.length());
int max = 0;
int cLength = 0;
int lastBegin = 0;
for(int i=0;i<s.length();i++){
Character ch = s.charAt(i);
if(crrent.containsKey(ch)){
int lastSameIndex = crrent.get(ch);
for(int j = lastBegin;j<=lastSameIndex;j++){
crrent.remove(s.charAt(j));
cLength--;
}
lastBegin = lastSameIndex+1;
}
cLength++;
max = Math.max(max,cLength);
crrent.put(ch,i);
}
return max;
}
}