Problem statement

https://binarysearch.com/problems/Check-Power-of-Two/

Solution

Equal to Leetcode 0231. Power of Two

Complexity

It is O(1) for time and space.

Code

class Solution:
    def solve(self, n):
        return not n&(n-1) and n != 0