Skip to content

Commit 8f8cd79

Browse files
committed
number of 1 bits solution
1 parent 707e607 commit 8f8cd79

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

number-of-1-bits/hyer0705.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
function hammingWeight(n: number): number {
2+
const RADIX = 2;
3+
4+
return n.toString(RADIX).match(/1/g)?.length || 0;
5+
}

0 commit comments

Comments
 (0)