Skip to content

Commit a343f3b

Browse files
committed
add cpp solution
1 parent 80b64af commit a343f3b

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
class Solution {
2+
public:
3+
bool isPowerOfTwo(int n) {
4+
long long x = n;
5+
if (x == 0) return false;
6+
return (x & (-x)) == x;
7+
}
8+
};

0 commit comments

Comments
 (0)