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
相关文章
- 12-01[LeetCode][Python]Longest Palindromic Substring
- 12-013. Longest Substring Without Repeating Characters (ASCII码128个,建立哈西表)
- 12-01LeetCode 3:Longest Substring Without Repeating Charact
- 12-01Longest Substring Without Repeating Characters 解决思路
- 12-013. Longest Substring Without Repeating Characters
- 12-01Leetcode第三题:Longest Substring Without Repeating Characters
- 12-01[LeetCode]3. Longest Substring Without Repeating Characters无重复字符的最长子串
- 12-01【Leetcode】【Medium】Longest Substring Without Repeating Characters
- 12-01No.003 Longest Substring Without Repeating Characters
- 12-01Leetcode 3. Longest Substring Without Repeating Characters (Medium)