bit manipulate according to #Power of Two. If num & (num-1) = 0, then num is power of two. If num is power of two and (num-1)%3 = 0, then num is power of four.
class Solution:
def isPowerOfFour(self, num: int) -> bool:
if num < 0:
return False
if num & (num-1) != 0:
return False
if (num-1)%3 != 0:
return False
return True