```
class Solution(object):
def lengthOfLongestSubstring(self, s):
"""
:type s: str
:rtype: int
"""
if len(s) < 1:
return 0
htab = {}
lsub = 0
i = 0
while i < len(s):
if s[i] in htab:
i = htab[s[i]]
lsub = max(lsub,len(htab))
htab = {}
else:
htab[s[i]] = i
i+=1
return max(lsub, len(htab))
```