标签:char turn else sel start while out max end
class Solution:
def lengthOfLongestSubstring(self, s: str) -> int:
# outlier
if s == "":
return 0
if len(s) == 1:
return 1
max_i = 0
start = 0
end = 1
limit = int(len(s))
while end < limit:
if s[end] not in s[start:end]:
end += 1
if end - start > max_i:
max_i = end - start
else:
start = s[start:end].index(s[end]) + 1 + start
return max_i
LeetCode Google[01]: Longest Substring Without Repeating Characters
标签:char turn else sel start while out max end
原文地址:https://www.cnblogs.com/lywangjapan/p/12428069.html