JavaScript one line solution


  • 1
    D
    /**
     * @param {number} x
     * @param {number} y
     * @return {number}
     */
    var hammingDistance = function(x, y) {
    	return new Number(x ^ y).toString(2).replace(/0/g, '').length;
    };
    

Log in to reply
 

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