Number of 1 Bits LeetCode solution in Java

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

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0