C++ , this method can solve the same question faster.


  • 0
    B

    class Solution {
    public:
    bool isPowerOfFour(int num) {
    if(!(num>0))
    return false;
    double temp = log(num)/log(4);
    int tempInt = (int) (temp+0.5);
    if(abs(temp-tempInt)<1e-10)
    return true;
    else
    return false;
    }
    };


Log in to reply
 

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