Golang | Leetcode Golang题解之第205题同构字符串

题目:

题解:

Go 复制代码
func isIsomorphic(s, t string) bool {
    s2t := map[byte]byte{}
    t2s := map[byte]byte{}
    for i := range s {
        x, y := s[i], t[i]
        if s2t[x] > 0 && s2t[x] != y || t2s[y] > 0 && t2s[y] != x {
            return false
        }
        s2t[x] = y
        t2s[y] = x
    }
    return true
}
相关推荐
wabs66613 小时前
关于二叉树【力扣199.二叉树的右视图的思考】
数据结构·c++·算法·leetcode·二叉树·层序遍历
a1879272183114 小时前
【算法】动态规划第三篇:背包第一课——贪心之死与正序倒序开关
算法·leetcode·动态规划·贪心·dp·暴力·算法讲解
Cccp.12314 小时前
【leetcode】(四)排序算法汇总和链表
leetcode·链表·排序算法
ttwuai15 小时前
Go 后台初始化 MySQL 脚本失败怎么办?先查 DDL 还是生成配置
开发语言·mysql·golang
名字还没想好☜15 小时前
Go 的 TCP 粘包与拆包:用长度前缀协议 + bufio 正确读消息
后端·tcp/ip·golang·go·php
a1879272183115 小时前
【算法】动态规划第五篇:区间 DP——从“看什么都像背包“到“最后戳谁“
算法·leetcode·动态规划·dp·区间·区间dp·算法讲解
rannn_11116 小时前
【力扣hot100】多维动态规划|62、64、5、1143、72
算法·leetcode·动态规划
计科杨某人17 小时前
简单算法题(基础入门题)
c++·算法·题解·入门·基础算法
find1star1 天前
LeetCode 141:环形链表
java·算法·leetcode·链表
LB21121 天前
力扣160 21 86
算法·leetcode·职场和发展