class Solution {
public:
bool isPowerOfFour(int num) {
/* == 的优先级大于 & */
return (num > 0) && ((num & (num-1)) == 0) && ((num-1) % 3 == 0);
}
};
LeetCode 342. Power of Four
最新推荐文章于 2024-06-04 11:17:38 发布
class Solution {
public:
bool isPowerOfFour(int num) {
/* == 的优先级大于 & */
return (num > 0) && ((num & (num-1)) == 0) && ((num-1) % 3 == 0);
}
};