205. 同构字符串 - 力扣(LeetCode)
class Solution:def isIsomorphic(self, s: str, t: str) -> bool:if len(s) != len(t):return Falsemapping_s_t = {}mapping_t_s = {}for char_s, char_t in zip(s, t):# 检查 s -> t 的映射if char_s in mapping_s_t:if mapping_s_t[char_s] != char_t:return Falseelse:mapping_s_t[char_s] = char_t# 检查 t -> s 的映射if char_t in mapping_t_s:if mapping_t_s[char_t] != char_s:return Falseelse:mapping_t_s[char_t] = char_sreturn True