程式語言 - LeetCode - C++ - 342. Power of Four



題目:


解答:

class Solution {
public:
    bool isPowerOfFour(int n) {
        return (n > 0) &&
            ((n & (n - 1)) == 0) &&
            ((n & 0x55555555) != 0);
    }
};