Skip to content

Commit 3366f2d

Browse files
committed
Time: 0 ms (100.00%) | Memory: 7.9 MB (18.55%) - LeetSync
1 parent 60606dc commit 3366f2d

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

231-power-of-two/power-of-two.cpp

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+
if(n == 0) return false;
5+
if(n == 1) return true;
6+
return (n%2==0)?isPowerOfTwo(n/2):false;
7+
}
8+
};

0 commit comments

Comments
 (0)