longest_substring_without_repeating_characters
2022-12-14
浏览 (867)
longest_substring_without_repeating_characters.py 源码
class Solution:
def lengthOfLongestSubstring(self, s: str) -> int:
res, m = 0, {}
for c in s:
if c in m:
res = max(res, len(m))
m.clear()
m[c] = 1
return max(res, len(m))
if __name__ == "__main__":
sol = Solution()
r = sol.lengthOfLongestSubstring("abcabcbb")
print(r)
你可能感兴趣的文章
first_unique_char
implement_strstr
is_palindrome
- 所属分类: 后端技术
- 本文标签:
技术
- 版权声明: 本文链接 https://seaxiang.com/blog/d4dcd7c44cbd4ec68a2ddfa7c914a592