给定一个字符串 s ,请你找出其中不含有重复字符的 最长子串 的长度
代码展示:
class Solution(object):
def lengthOfLongestSubstring(self, s):
"""
:type s: str
:rtype: int
"""
temp=""
length=0
for i in s:
if i not in temp:
temp += i
length = max(length,len(temp))
else:
temp += i
temp = temp[temp.index(i)+1 :]
return length
测试结果展示:



