class Solution(object):

def lengthOfLongestSubstring(self, s):

"""

:type s: str

:rtype: int

"""

first=0

MaxL=0

NewMax=0

for i in range(len(s)):

if s[i] not in s[first:i]:

MaxL+=1

else:

newfirst=s[first:i].index(s[i])+1

first+=newfirst

MaxL=MaxL-newfirst+1

NewMax=max(MaxL,NewMax)

return NewMax