funclengthOfLongestSubstring(s string) int {var bitSet [256]bool res, left, right :=0, 0, 0for left <len(s) {if right >=len(s) {break }if bitSet[s[right]] { bitSet[s[left]] =false left++ } else { bitSet[s[right]] =true right++ }if right - left > res { res = right - left } }return res}
We use a BitSet to mark if a single character is repeated or not.