4 ms very simple Java solution


  • 0
    S
    public boolean isPowerOfFour(int num) {
            if (num == 0) {
                return false;
            }
    
            double result = Math.log(num) / Math.log(4.0);
            return result == Math.floor(result);
        }
    

Log in to reply
 

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