2023每日刷题(五十)
Leetcode—205.同构字符串

算法思想
参考自k神思路
 
实现代码
class Solution {
public:
    unordered_map<char, char> s2t, t2s;
    bool isIsomorphic(string s, string t) {
        int n = s.size();
        for(int i = 0; i < n; i++) {
            char x = s[i], y = t[i];
            if(s2t.find(x) != s2t.end() && s2t[x] != y || t2s.find(y) != t2s.end() && t2s[y] != x) {
                return false;
            }
            s2t[x] = y;
            t2s[y] = x;
        }
        return true;
    }
};
 
运行结果

 之后我会持续更新,如果喜欢我的文章,请记得一键三连哦,点赞关注收藏,你的每一个赞每一份关注每一次收藏都将是我前进路上的无限动力 !!!↖(▔▽▔)↗感谢支持!



















