Skip to content

Commit 13718df

Browse files
committed
Time: 4 ms (36.64%), Space: 5.9 MB (47.76%) - LeetHub
1 parent 96a839a commit 13718df

File tree

1 file changed

+13
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)