My one line solution in C++ using bitwise


  • 0
    T

    class Solution {
    public:

    bool isPowerOfFour(int num) {
        return (num && !(num & (num-1)) && !(num & 0xAAAAAAAA));
    }
    

    };


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.