my javascript solution


  • 0
    Z
    /**
     * @param {string} s
     * @param {string} t
     * @return {boolean}
     */
    function isIsomorphic(s, t) {
        if (s.length !== t.length) {
            return false;
        }
        const sMap = {}, tMap = {};
        for (let i = 0; i < s.length; i++) {
            if (sMap[s[i]] != tMap[t[i]]) {
                return false;
            }
            sMap[s[i]] = i;
            tMap[t[i]] = i;
        }
        return true;
    }
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.