JavaScript solution, 87ms


  • 0
    M
    var findTheDifference = function(s, t) {
        
        var sTotaler = 0;
        var tTotaler = 0;
        var sArr = s.split('');
        var tArr = t.split('');
        
        for (var i = 0; i < sArr.length; i++) {
        	sTotaler += sArr[i].charCodeAt(0);
        }
    
        for (var i = 0; i < tArr.length; i++) {
        	tTotaler += tArr[i].charCodeAt(0);
        }
    
        return String.fromCharCode(Math.abs(sTotaler - tTotaler));
    };
    

Log in to reply
 

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