def isIsomorphic(self, s, t):
if len(s) != len(t):
return False
for i in range(len(s)):
if occurence(s, s[i]) != occurence(t, t[i]):
return False
return True
# def isIsomorphic(self, s, t):
# if len(s) != len(t):
# return False
# lens = len(s)
# s_dict = ''
# t_dict = ''
# for idx, ele in enumerate(s):
# if ele not in s_dict:
# s_dict += ele
# t_dict += t[idx]
# translated = s.translate(maketrans(s_dict, t_dict))
# print translated, t
# if translated == t:
# return True
# return False
评论列表
文章目录