Bit Manipulation - Power of Two
Given the following code, what is the output of
isPowerOfTwo(16) and isPowerOfTwo(218)?
def isPowerOfTwo(n: int) -> bool:
if n <= 0:
return False
return bin(n).count('1') == 1
print(isPowerOfTwo(16))
print(isPowerOfTwo(218))
