Skip to content

Commit 18e8e78

Browse files
committed
cpp
1 parent 8d774bd commit 18e8e78

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

Feb 2021 challeneg day 1.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
class Solution {
2+
public:
3+
int hammingWeight(uint32_t n) {
4+
int res = 0;
5+
while(n)
6+
{
7+
n &= n - 1;
8+
++ res;
9+
}
10+
return res;
11+
}
12+
};

0 commit comments

Comments
 (0)