```
class Solution(object):
def lengthOfLongestSubstring(self, s):
"""
:type s: str
:rtype: int
"""
if not s:
return 0
i,j,m,n=0,0,0,len(s)
while j<n:
if s[j] not in s[i:j]:
j+=1
m=max(m,j-i)
else:
i+=1
return m
```