Javascript solution using log10 (Beats 85%)


  • 0
    R
    var isPowerOfFour = function(num) {
        if(num <= 0 || num > Number.MAX_SAFE_INTEGER)
            return false;
        
        var res = (Math.log10(num)/Math.log10(4))%1;
        
        return res === 0?true:false;
        
    };

Log in to reply
 

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