Why Time Limit Exceed?


  • 0
    M
    class Solution(object):
        def isIsomorphic(self, s, t):
            """
            :type s: str
            :type t: str
            :rtype: bool
            """
            if len(s) == len(t):
                slen = len(s)
                d = dict()
                i = 0 
                while i in xrange(slen):
                    print s[i],d
                    if s[i] in d:
                        if t[i] != d[s[i]]:
                            return False
                    else:
                        d[s[i]]=t[i]
                    
                    i+=1
                
                return True
                        
            return False

  • 0
    Q

    maybe you should comment the printing statement


Log in to reply
 

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