哈希
class Solution{
public int lengthOfLongestSubstring(String s){
int Max=0,left=0,right=0;
char[] charArray=s.toCharArray();
Set<Character> set=new HashSet<>();
for(int i=0;i<s.length();i++){
while(set.contains(charArray[i]))
set.remove(charArray[left++]);
set.add(charArray[i]);
int temp=right-left+1;
right++;
Max=Max>temp?Max:temp;
}
return Max;
}
}