Skip to content

Commit

Permalink
Create 191. Number of 1 Bits (#353)
Browse files Browse the repository at this point in the history
  • Loading branch information
Chayandas07 authored Nov 29, 2023
2 parents df654e2 + f976cec commit 8d2d709
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions 191. Number of 1 Bits
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
class Solution {
public:
#define DPSolver ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
int hammingWeight(uint32_t n) {
DPSolver;
int counter = 0;
while(n){
counter += n&1;
n>>=1;
}
return counter;
}
};

0 comments on commit 8d2d709

Please sign in to comment.