题目 Given an integer (signed 32 bits), write a function to check whether it is a power of 4. 解题思路 一个数是4的幂一定是2的幂,区别是对3取余的结果不同 代码 class Solution: def isPowerOfFour(self, num: int) -> bool: return num > 0 and num & (num - 1) == 0 and num % 3 == 1 视频讲解 YouTube<--欢迎点击订阅 视频讲解 bilibili<--欢迎点击订阅 Previous LeetCode 125 Valid Palindrome (Python) Next LeetCode 211 Add and Search Word - Data structure design (Python)