Simple python solution


  • 0
    A
    def isIsomorphic(s, t):
            d1,d2={},{}
            for a,b in zip(s,t):
                if a not in d1:
                    d1[a]=b
                else:
                    if d1[a]!=b:
                        return False
                if b not in d2:
                    d2[b]=a
                else:
                    if d2[b]!=a:
                        return False
            return True

Log in to reply
 

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