class Solution {
public:
    int hammingWeight(uint32_t n) {
        int res = 0;
        for (int i = 0; i < 32; ++i) {
           res+=0x1&(n>>i);
        }
        return res;
    }
};

相关文章:

  • 2021-07-02
  • 2021-12-04
  • 2021-10-29
  • 2022-01-22
  • 2021-10-28
  • 2022-12-23
  • 2021-06-30
  • 2021-08-17
猜你喜欢
  • 2022-12-23
  • 2022-01-11
  • 2022-01-09
  • 2021-06-16
  • 2022-03-07
相关资源
相似解决方案