leetcode 3-> Longest Substring Without Repeating Characters

 

class Solution(object):
    def lengthOfLongestSubstring(self, s):
        d = ""
        f = ""
        for i in range(len(s)):
            if s[i] not in f:
                f += s[i]
            else:
                if len(d) < len(f):
                    d = f
                f = f[f.index(s[i])+1::] + s[i]
              
        return max(len(d), len(f))

 

 

posted @ 2019-03-04 10:32  anobscureretreat  阅读(138)  评论(0编辑  收藏  举报