```
def lengthOfLongestSubstring(self, s):
"""
:type s: str
:rtype: int
"""
if len(s) is 0 or len(s) is 1:
return len(s)
len1 = 1
temp = ''
for i in range(len(s)):
if s[i] in temp:
start = s[:i].rindex(s[i])
temp = s[start+1:i+1]
else:
temp += s[i]
if len(temp) > len1:
len1 = len(temp)
return len1
```