Tianhe Gao

LC 461. Hamming Distance

 1/**
 2 * @param {number} x
 3 * @param {number} y
 4 * @return {number}
 5 */
 6var hammingDistance = function (x, y) {
 7  let s = x ^ y, ret = 0
 8  while (s != 0) {
 9    ret += s & 1
10    s >>= 1
11  }
12  return ret
13};

No notes link to this note

Welcome to tell me your thoughts via "email"
UP