无重复字符的最长子串


Published: 周六 26 一月 2019

In Leetcode.

class Solution:
    def lengthOfLongestSubstring(self, s):
        max_ = 0
        string_ = ''
        for i in s:
            if i in string_:
                string_ = string_[string_.index(i)+1:] + i
            else:
                string_ += i
                if len(string_) > max_:
                    max_ = len(string_)

        return max_