Easy Java Solution 2ms


  • 0
    A

    public class Solution {
    // you need to treat n as an unsigned value
    public int hammingWeight(int n) {
    return Integer.bitCount(n);
    }
    }


Log in to reply
 

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