Python Solution


  • 0
    O
    class Solution:
        # @param {string} s
        # @param {string} t
        # @return {boolean}
        def isIsomorphic(self, s, t):
            if s==t:
                return True
            dic={}
            for i in range(len(s)):
                k=s[i]
                if not dic.has_key(k):
                    if t[i] not in dic.values():
                        dic[k]=t[i]
                    else:
                        return False
                elif t[i]!=dic[k]:
                    return False
            
            return True

Log in to reply
 

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