首页 > 编程语言 >python 无重复字符的最长子串

python 无重复字符的最长子串

时间:2023-01-13 10:06:13浏览次数:42  
标签:子串 字符 temp python Solution lengthOfLongestSubstring kk length print


class Solution(object):
def lengthOfLongestSubstring(self, s):
"""
:type s: str
:rtype: int
"""
temp = ''
length = 0
for i in s:
if i not in temp:
temp+=i
length = max(length,len(temp))
else:
temp+=i

kk=temp.index(i)
print('kk=',kk)
temp = temp[kk+1:]
print(temp)

return length


a='baaaabcdea'

c=Solution()

c1=c.lengthOfLongestSubstring(a)

print(c1)


标签:子串,字符,temp,python,Solution,lengthOfLongestSubstring,kk,length,print
From: https://blog.51cto.com/u_15202985/6005772

相关文章