leetcode 3

Posted 东东就是我

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了leetcode 3相关的知识,希望对你有一定的参考价值。

class Solution(object):
    def lengthOfLongestSubstring(self, s):
        """
        :type s: str
        :rtype: int
        """
        r,l,n=0,0,0
        while l<=len(s):
            if len(s[r:l])==len(set(s[r:l])):
                if n<len(s[r:l]):
                    n=len(s[r:l])
                l+=1
            else:
                r+=1
                l+=1

        return n

以上是关于leetcode 3的主要内容,如果未能解决你的问题,请参考以下文章