0
点赞
收藏
分享

微信扫一扫

磁力猫磁力搜索大全教程,如何使用磁力链接。

非衣所思 2024-07-24 阅读 28

LeetCode 205. 同构字符串

哈希表,还是用两个哈希表构建双射关系比较合适

class Solution:
    def isIsomorphic(self, s: str, t: str) -> bool:
        length = len(s)
        d = {}
        for i in range(length):
            if s[i] not in d:
                d[s[i]] = t[i]
            else:
                if d[s[i]] != t[i]:
                    return False
        return len(set(d.keys())) == len(set(d.values()))
举报

相关推荐

0 条评论