2023-07-21 13:06:08 +0000 UTC
Power of Two
Categories:
Links
Code
class Solution:
def isPowerOfTwo(self, n: int) -> bool:
if n == 1:
return True
while n > 2 and not n % 2:
n //= 2
return n == 2