标签:ring max bst rac length sub sts character contain
public int lengthOfLongestSubstring(String s) {
int i = 0, j = 0, max = 0;
Set<Character> set = new HashSet<>();
while(j < s.length()){
if(! set.contains(s.charAt(j)) ){
set.add(s.charAt(j++));
max = Math.max(max, set.size());
}else{
set.remove(s.charAt(i++));
}
}
return max;
}
leetcode 3. Longest Substring Without Repeating Characters [java]
标签:ring max bst rac length sub sts character contain
原文地址:https://www.cnblogs.com/whyaza/p/10658371.html