Skip to content

Instantly share code, notes, and snippets.

@RP-3
Created July 5, 2020 22:54
Show Gist options
  • Save RP-3/202125e113a1c5bc733d9a18ca23cf72 to your computer and use it in GitHub Desktop.
Save RP-3/202125e113a1c5bc733d9a18ca23cf72 to your computer and use it in GitHub Desktop.
/**
* @param {number} x
* @param {number} y
* @return {number}
*/
var hammingDistance = function(x, y) {
let [diffs, result] = [x ^ y, 0];
while(diffs){
result += diffs & 1;
diffs = diffs >> 1;
}
return result;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment