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
相关文章
- 03-18leetcode 最大不重复字符
- 03-18【每日Leetcode-第三天】无重复字符的最长子串
- 03-18leetCode刷题(找到最长的连续不重复的字符串长度)
- 03-18【leetcode】3无重复字符的最长子串
- 03-18【LeetCode】1668.最大重复子字符串(三)
- 03-18LeetCode之无重复字符串的最大子串(三)
- 03-18LeetCode424. 替换后的最长重复字符(双指针:滑动窗口)
- 03-18leetcode刷题第三天<无重复字符的最长子串>
- 03-18[leetcode 周赛 149] 1156 单字符重复子串的最大长度
- 03-18[LeetCode]3. Longest Substring Without Repeating Characters无重复字符的最长子串