4ms C solution without iteration


  • 0
    bool isPowerOfFour(int num) {
        long magic = 0x40000000;
        int root;
        if (num < 1) return false;
        else if (magic % num != 0) return false; 
        else{
            root =  (int)sqrt(num);
            return ( root*root == num ) ? true : false;
        }
    }

Log in to reply
 

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