Given an integerĀ n, returnĀ trueĀ if it is a power of two. Otherwise, returnĀ false.

An integerĀ nĀ is a power of two, if there exists an integerĀ xĀ such thatĀ n == 2x.

solution

def isPowerOfTwo(self, n: int) -> bool:
	# no negatives can be power of two
	# n = 10000
	# n-1 = 01111
	# n&(n-1) = 00000
	return n > 0 and n&(n-1) == 0