My cpp code without loop


  • 0
    C
    class Solution {
    public:
        bool isPowerOfFour(int num) 
        {
            if(num <= 0) return false;
            if((num & (num-1)) != 0) return false;
            return num & 0x55555555;
        }
    };

Log in to reply
 

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