class Solution:
def lengthOfLongestSubstring(self, s):
max_ = 0
string_ = ''
for i in s:
if i in string_:
string_ = string_[string_.index(i)+1:] + i
else:
string_ += i
if len(string_) > max_:
max_ = len(string_)
return max_
近期评论