class Solution(object):
def isIsomorphic(self, s, t):
"""
:type s: str
:type t: str
:rtype: bool
"""
l = len(s)
print(l)
#两次遍历
a = {}
for i in range(l):#从0到l
if s[i] not in a:
a[s[i]] = t[i]
else:
if a[s[i]] is not t[i]:
return False
b = {}
for i in range(l):#从0到l
if t[i] not in b:
b[t[i]] = s[i]
else:
if b[t[i]] is not s[i]:
return False
return True
【python】205. Isomorphic Strings
猜你喜欢
转载自blog.csdn.net/acbattle/article/details/80468850
今日推荐
周排行