Power of Four

Solution Code
class Solution:
    def isPowerOfFour(self, n: int) -> bool:
        if n <= 0: return False
        while n % 4 == 0:
            n //= 4
        return n == 1
Video GuideLeetcode Daily

Time Complexity

O(1)

Space Complexity

O(1)