题解 | #2的幂#
2的幂
https://www.nowcoder.com/practice/4a04240fd2be4e1287aab4af067f6d8f
#
# 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
#
#
# @param n int整型
# @return bool布尔型
#
class Solution:
def poweroftwo(self , n: int) -> bool:
# write code here
if n==0:
return False
else:
lst1=[]
for i in str(bin(n)):
lst1.append(i)
lst1.pop(0)
lst1.pop(0)
for i in range(1,len(lst1)):
if lst1[i] == '1':
return False
return True