Leetcode 231 Solution

This article provides solution to leetcode question 231 (power-of-two)

https://leetcode.com/problems/power-of-two

Solution

class Solution:
    def isPowerOfTwo(self, n: int) -> bool:
        return n & (n - 1) == 0 and n != 0