My Python solution - 116ms


  • 0
    W
    class Solution(object):
        def lengthOfLongestSubstring(self, s):
            """
            :type s: str
            :rtype: int
            """
            subStr=''
            maxLength=0
            for i in range(0,len(s)):
                if subStr.find(s[i])!=-1:
                    subStr=subStr[subStr.find(s[i])+1:]+s[i]
                else:
                    subStr+=s[i]
                maxLength=max(maxLength,len(subStr))
                        
            return maxLength
                    
    

Log in to reply
 

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