Skip to content

Commit 68407bf

Browse files
committed
feat: number-of-1-bits solution
1 parent d740e70 commit 68407bf

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

number-of-1-bits/sm9171.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
public static int hammingWeight(int n) {
2+
int sum = 0;
3+
while (n > 0) {
4+
sum += n % 2;
5+
n /= 2;
6+
}
7+
return sum;
8+
}

0 commit comments

Comments
 (0)