Leetcode3:無重複字元的最長子串python實現 阿新 • • 發佈:2021-01-28 技術標籤:Leetcodepythonleetcode正則表示式字串 給定一個字串,請你找出其中不含有重複字元的最長子串的長度。 class Solution: def lengthOfLongestSubstring(self, s: str) -> int: za="" zb="" for i in s: if i not in za: za =za +i else: za =za[za.index(i)+1:] za =za + i if len(za)>len(zb): zb=za return len(zb)