标签:rip image 位移 class pre mic UNC return 操作
解法:
var hammingWeight = function (n) { let ans = 0; let mask = 1; for (let i = 0; i < 32; i++) { ans += (n & mask) == 0 ? 0 : 1; mask = mask << 1; } return ans; };
var hammingWeight = function (n) { let ans = 0; while (n != 0) { ans++; n = n & (n - 1); } return ans; };
标签:rip image 位移 class pre mic UNC return 操作
原文地址:https://www.cnblogs.com/JosephWong/p/13720072.html