leetcode 最大不重复字符

class Solution:
def lengthOfLongestSubstring(self, s: str) -> int:
if len(s) <= 1:
return len(s)
d = set(s)
s = list(s)
dic = {}
exit1 = []
ma = 1
n = 0
index = 0
start = 0
s_l = len(s)
d_l = len(d)
end = d_l
if s_l == d_l:
return s_l
for i in range(s_l):
s1 = s.copy()
while s1 != []:
k = s1.pop(0)
if k not in exit1:
exit1.append(k)
n += 1
else:
exit1 = list()
if n > ma:
ma = n
if ma >= d_l:
return ma
n = 0
break
s.pop(0)
return ma

上一篇:Springboot集成MapperFactory(ma.glasnost.orika.MapperFactory)类属性复制


下一篇:16-成绩3