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
}
相关推荐
8Qi83 小时前
LeetCode 235. 二叉搜索树的最近公共祖先(LCA)
算法·leetcode·二叉树·递归·二叉搜索树·lca·迭代
李燚4 小时前
Eino 的 ReAct 循环是怎么跑起来的:图、节点、分支
golang·agent·react·ai-agent
8Qi85 小时前
LeetCode 494:目标和(Target Sum)—— 题解 ✅
算法·leetcode·职场和发展·动态规划·01背包
这料鬼有毒7 小时前
二刷hot100-78.子集
算法·leetcode·职场和发展
Hiter_John8 小时前
Golang的运算符
开发语言·后端·golang
Hiter_John9 小时前
Golang的变量常量初始化
开发语言·后端·golang
医用门10 小时前
医院钢制门厂家有哪些品牌好的
leetcode
mifengxing10 小时前
LeetCode热题100——字母异位词分组
java·算法·leetcode·职场和发展·哈希表·hot100
小欣加油12 小时前
leetcode41 缺失的第一个正数
数据结构·c++·算法·leetcode
必胜刻12 小时前
一个异步生成游戏功能的落地复盘:Redis Stream + WebSocket + 状态补偿
redis·websocket·golang·gin·状态补偿