5 lines C++ solution


  • 0
    J
    class Solution {
    public:
        bool isPowerOfFour(int num) {
            if(num<=0) return false;
            long product = pow(2,31);
            int n = sqrt(num);
            if(n*n!=num) return false;
            return product%n==0;
        }
    };

Log in to reply
 

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