```
class Solution(object):
def lengthOfLongestSubstring(self, s):
"""
:type s: str
:rtype: int
"""
length = len(s)
max_len = 0
i, j, loc1, loc2 = 0, 0, 0, 0
while i < length:
j = loc1
while j < i:
if s[j] == s[i]:
if i - loc1 > max_len:
max_len = i - loc1
loc1 = j + 1
j += 1
i += 1
if i - loc1 > max_len:
max_len = i - loc1
return max_len
```