Javascript using XOR - beats 100% solutions


  • 0
    R
    var findTheDifference = function(s, t) {
        var size = s.length,
        	i,
        	result = t.charCodeAt(size);
        
        for(i = 0; i < size; i++){
        	result ^= s.charCodeAt(i) ^ t.charCodeAt(i);
        }
        
        return String.fromCharCode(result);
    };

Log in to reply
 

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