class Solution:
def isIsomorphic(self, s: str, t: str) -> bool:
# intuition -> using dictionary
dic = {} # s : t 치환관계 맵핑
check = [] # t가 치환된적 있는지 확인
sList = list(s)
tList = list(t)
for i in range(len(sList)):
if sList[i] not in dic and check.count(tList[i]) == 0:
# s, t가 각각 dic, check에 없는 경우
dic[sList[i]] = tList[i]
check.append(tList[i])
elif sList[i] not in dic and check.count(tList[i]) == 1:
# s는 dic에 없는데 해당 문자가 이미 check에 있을때 s = "badc", t = "baba"
return False
elif sList[i] in dic and dic[sList[i]] != tList[i]:
# s가 dic에 등록됐는데 해당 문자가 안나올때 s = "foo", t = "bar"
return False
return True