https://leetcode.com/problems/isomorphic-strings/
class Solution: def isIsomorphic(self, s: str, t: str) -> bool: dict = {} if len(s) != len(t): return False for i, j in zip(s, t): if i != j: if i not in dict: dict[i] = j else: if dict[i] != j: return False else: dict[i] = j return True
时间复杂度:O() 空间复杂度:O()
Last updated 10 months ago