Javascript solution


  • 0
    R
    var isIsomorphic = function(s, t) {
        
        var helpFuc = function(s, t){
            if(s.length !== t.length) return false;
        
            var hashT = {};
        
            for(var i = 0; i < s.length; i++){
                if(!(s[i] in hashT)) hashT[s[i]] = t[i];
                
                if(hashT[s[i]] !== t[i]) return false;
            }
        
            return true;
        };
        
        return helpFuc(s,t) && helpFuc(t, s);
        
    };

Log in to reply
 

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