Here is the implementation:
function lengthOfLongestSubstring(s):
seen = empty set
left = 0
maxLen = 0
for right from 0 to s.length - 1:
while s[right] in seen:
seen.remove(s[left])
left += 1
seen.add(s[right])
maxLen = max(maxLen, right - left + 1)
return maxLen
time (each character added/removed once), space for the set.