题目链接
给定一个字符串,请你找出其中不含有重复字符的 最长子串 的长度
class Solution:
def lengthOfLongestSubstring(self, s: str) -> int:
maxl = 0
son_s = []
for i in range(len(s)):
try:
index = son_s.index(s[i])
maxl = max(maxl,len(son_s))
son_s = son_s[index+1:]
except:
pass
son_s.append(s[i])
maxl = max(maxl,len(son_s)) # 边界情况
return maxl
原文:https://www.cnblogs.com/Lzqayx/p/12124076.html