AC results in Python, beat 93%


  • 2
    X
    def isIsomorphic(self, s, t):
        """
        :type s: str
        :type t: str
        :rtype: bool
        """
        found = {}
        
        for i in range(len(s)):
            if s[i] in found:
                if not found[s[i]] == t[i]:
                    return False
                
            else:
                if t[i] in found.values():
                    return False
                found[s[i]] = t[i]
                
        return True

Log in to reply
 

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