Skip to content

Commit 47f575e

Browse files
authored
Create 21 May Check if All Bits Set (#1082)
2 parents 48b7b66 + 0c1cdd1 commit 47f575e

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

21 May Check if All Bits Set

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
class Solution {
2+
public:
3+
bool isBitSet(int n) {
4+
// code here
5+
int x=__builtin_popcount(n); //setbit
6+
int y=log2(n)+1; //size
7+
return x==y;
8+
}
9+
};

0 commit comments

Comments
 (0)