Isomorphic Strings
class Solution(object):
def isIsomorphic(self, s, t):
"""
:type s: str
:type t: str
:rtype: bool
"""
hashmapS,hashmapT = {}, {}
for i in range(len(s)):
if hashmapS.get(s[i]):
if hashmapS[s[i]] != t[i]:
return False
else:
if hashmapT.get(t[i]):
return False
hashmapS[s[i]] = t[i]
hashmapT[t[i]] = s[i]
return TrueLast updated