class Solution:
def lengthOfLongestSubstring(self, s: str) -> int:
if len(s)==0 or len(s)==1:
return len(s)
temp=[]
maxlen=0
for i in s:
if i in temp:
if len(temp)>maxlen:
maxlen=len(temp)
temp=temp[temp.index(i) + 1:]#把重复之前的都删掉,例如dabc,i=a删去da
temp.append(i)
if len(temp) > maxlen:
maxlen = len(temp)
return maxlen