Files
leetcode/231-power-of-two/231-power-of-two.py
T

5 lines
140 B
Python

class Solution:
def isPowerOfTwo(self, n: int) -> bool:
if n < 0:
return False
return bin(n).count("1") == 1