Problem: Longest substring without repeating characters.
function lengthOfLongestSubstring(s):
charSet = empty set
left = 0, maxLen = 0
for right from 0 to s.length - 1:
while s[right] in charSet:
charSet.remove(s[left])
left++
charSet.add(s[right])
maxLen = max(maxLen, right - left + 1)
return maxLen
Example: "abcabcbb" → max ("abc").
Time: . Space: .