def lengthOfLongestSubstring(self, s):
if len(s) == 0:
return 1
else:
self.l = ''
self.count = 0
self.mlist = []
length =0
for i in s:
if i not in self.l:
self.l += i
self.count +=1
elif i in self.l:
self.mlist.append(self.count)
self.count =0
self.l = ''
self.l +=i
self.count +=1
#return max(self.mlist)
for i in self.mlist:
if i > length:
length = i
return length
a = Solution()
print(a.lengthOfLongestSubstring(""))
No comments:
Post a Comment