205. Isomorphic Strings

class Solution(object):
    def isIsomorphic(self, s, t):
        """
        :type s: str
        :type t: str
        :rtype: bool
        """
        sTable={}
        tTable={}
        for i in xrange(len(s)):
            if s[i] not in sTable and t[i] not in tTable :
                sTable[s[i]]=i
                tTable[t[i]]=i
            elif s[i] not in sTable or t[i] not in tTable:
                return False
            elif sTable[s[i]]!=tTable[t[i]]:
                return False
        return True
        

你可能感兴趣的:(205. Isomorphic Strings)