class Solution:
def lengthOfLongestSubstring(self, s):
"""
:type s: str
:rtype: int
"""
length = len(s)
data = dict()
cur = ''
max = 0
for i in range(length):
c = s[i]
index = cur.find(c)
if index == -1:
cur += c
else:
l = len(cur)
if cur not in data:
data[cur] = l
if l > max:
max = l
if index == l - 1:
cur = c
else:
cur = cur[index + 1:] + c
l = len(cur)
if cur not in data:
if l > max:
max = l
return max