标签:最长子串 end class cep try 字符串 题目 pen rac
题目链接
给定一个字符串,请你找出其中不含有重复字符的 最长子串 的长度
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
标签:最长子串 end class cep try 字符串 题目 pen rac
原文地址:https://www.cnblogs.com/Lzqayx/p/12124076.html