IT/코딩테스트
[Leetcode] 205. Isomorphic Strings
이주디
2024. 4. 2. 21:49
728x90
https://leetcode.com/problems/isomorphic-strings
class Solution:
def isIsomorphic(self, s: str, t: str) -> bool:
mapping = {}
for i, c in enumerate(s):
if mapping.get(c, None) is None:
if t[i] in mapping.values():
return False
mapping[c] = t[i]
else:
if mapping[c] != t[i]:
return False
return True
728x90