LovePinkLol-Python Programming
Saturday, November 25, 2017
231. Power of Two
class Solution:
def isPowerOfTwo(self, n):
"""
:type n: int
:rtype: bool
"""
if bin(n)[2] == "1" and bin(n)[3:] == (len(bin(n))-3) * "0":
return True
else:
return False
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment