Python Solution


  • -4
    C

    class Solution(object):

    def lengthOfLongestSubstring(self, s):
        """
        :type s: str
        :rtype: int
        """
        b=""
        max=""
        for c in s:
            if c not in b: 
                b+=c
                if len(max)<len(b):max=b
            else:
                b=b[b.index(c)+1:]+c
            
        return len(max)

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.