LeetCode Google[01]: Longest Substring Without Repeating Characters
Posted lywangjapan
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了LeetCode Google[01]: Longest Substring Without Repeating Characters相关的知识,希望对你有一定的参考价值。
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的主要内容,如果未能解决你的问题,请参考以下文章
LeetCode Google[01]: Longest Substring Without Repeating Characters
[LeetCode&Python] Problem 925. Long Pressed Name
Leetcode_easy925. Long Pressed Name
(Easy) Long Pressed Name LeetCode