class Solution(object):
def lengthOfLongestSubstring(self, s):
"""
:type s: str
:rtype: int
"""
if len(s) <= 0:
return 0
res = list()
maxLen = 0
for i in s:
if i in res:
tmpLen = len(res)
if tmpLen > maxLen:
maxLen = tmpLen
while True:
tmp = res.pop(0)
if tmp == i:
break
res.append(i)
else:
res.append(i)
cnt = len(res)
if cnt > maxLen:
maxLen = cnt
return maxLen
相关文章
- leetcode:Longest Substring Without Repeating Characters
- [LeetCode] Longest Substring Without Repeating Characters 最长无重复字符的子串
- 【LeetCode】3.Longest Substring Without Repeating Characters 最长无重复子串
- leetcode 3 Longest Substring Without Repeating Characters最长无重复子串
- [LeetCode] Longest Substring Without Repeating Characters 最长无重复子串
- [LeetCode] Longest Substring Without Repeating Characters 最长无重复字符的子串 C++实现java实现
- 395. Longest Substring with At Least K Repeating Characters
- LeetCode 3 Longest Substring Without Repeating Characters(最长不重复子序列)
- LeetCode 395. Longest Substring with At Least K Repeating Characters C#
- leetcode3 Longest Substring Without Repeating Characters