3. 无重复字符的最长子串

class Solution:
    def lengthOfLongestSubstring(self, s: str) -> int:
        res = ''
        front, back = 0, 0
        maxlen = 0

        while front < len(s) and back < len(s):
            
           
            if s[front] not in res:
                print(maxlen)
                res = res + s[front]
                front += 1
            else:
                res = res[1:]
                back += 1
            maxlen = max(len(res), maxlen)
        return maxlen
©️2020 CSDN 皮肤主题: 游动-白 设计师:上身试试 返回首页