3. 无重复字符的最长子串

给定一个字符串 s ,请你找出其中不含有重复字符的 最长子串 的长度。

s = "pwwkew"

max_lengh = 0
for it in range(len(s)):
    temp = []
    temp.append(s[it])
    for item in s[it+1:]:
        if item in temp:
            break
        else:
            temp.append(item)
    lengh = len(temp)
    if max_lengh<lengh:
        max_lengh = lengh

print(max_lengh)

 

posted @ 2022-01-30 20:23  我不知道取什么名字好  阅读(22)  评论(0编辑  收藏  举报