Accepted easy Java solution


  • 1
    J
    public int hammingWeight(int n) {
        int result=0;
        for(int i=0; i<32; i++){
            result += (n&1);
           n>>>=1;
        }
        return result;
    }

Log in to reply
 

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