Skip to content

Commit ec643ae

Browse files
committed
add solution
1 parent 17b1013 commit ec643ae

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

231-power-of-two.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# https://leetcode.com/problems/power-of-two/
2+
# https://leetcode.com/problems/power-of-two/discuss/63966/4-different-ways-to-solve-Iterative-Recursive-Bit-operation-Math
3+
4+
class Solution:
5+
def isPowerOfTwo(self, n: int) -> bool:
6+
return n > 0 and (n & (n - 1)) == 0

0 commit comments

Comments
 (0)