C++ 1 line bitset, no loop nor recursion


  • 0
    Z
    class Solution {
    public:
        int hammingWeight(uint32_t n) {
            return bitset<32>(n).count();
        }
    };
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.