class Solution { public: int hammingWeight(uint32_t n) { int res = 0; int i = 32; while (i--) { res += n & 1; n >>= 1; } return res; } };
2024-03-15 23:24:30
class Solution { public: int hammingWeight(uint32_t n) { int res = 0; int i = 32; while (i--) { res += n & 1; n >>= 1; } return res; } };