leetcode

Solution to some Leetcode problems written in C++
git clone git://git.dimitrijedobrota.com/leetcode.git
Log | Files | Refs | README | LICENSE

0191.cpp (166B)


      1 class Solution {
      2   public:
      3     int hammingWeight(uint32_t n) {
      4         int res = 0;
      5         while (n)
      6             res += n & 1, n >>= 1;
      7         return res;
      8     }
      9 };