1 min read
https://practice.geeksforgeeks.org/problems/set-bits0143/1
class Solution {
public:
int setBits(int N) {
int bCount = 0;
while (N) {
N &= (N - 1);
bCount++;
}
return bCount;
}
};
1 min read
https://practice.geeksforgeeks.org/problems/set-bits0143/1
class Solution {
public:
int setBits(int N) {
int bCount = 0;
while (N) {
N &= (N - 1);
bCount++;
}
return bCount;
}
};