4ms CPP with simple code


  • 0
    L

    int hammingWeight(uint32_t n) {

        int count=0;
        for(int i=0;i<32;i++){
            if((1<<i)&n) count++;
        }
        return count;
    

    }


Log in to reply
 

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