Skip to content

Commit eb1aecc

Browse files
authored
using bit manipulation
1 parent 1944e7c commit eb1aecc

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

Power of two

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
class Solution {
2+
public:
3+
bool isPowerOfTwo(int n)
4+
{
5+
if(n<=0)
6+
return false;
7+
return n && (!(n & (n-1)));
8+
}
9+
};

0 commit comments

Comments
 (0)