Power of Two
解题思路:
Python代码:
return n > 0 and n & (n - 1) == 0class Solution(object):
def isPowerOfTwo(self, n):
"""
:type n: int
:rtype: bool
"""
while n and n%2==0:
n=n/2
if n==1:
return True
return FalseLast updated