LC 461. Hamming Distance

/**
 * @param {number} x
 * @param {number} y
 * @return {number}
 */
var hammingDistance = function (x, y) {
  let s = x ^ y, ret = 0
  while (s != 0) {
    ret += s & 1
    s >>= 1
  }
  return ret
};
欢迎通过「邮件」或者点击「这里」告诉我你的想法
Welcome to tell me your thoughts via "email" or click "here"