Simple solution without loop and recursion,Java


  • 0
    D
    public class Solution {
        public boolean isPowerOfFour(int num) {
            String number = Integer.toBinaryString(num);
            if(number=="1")return true;
            if(number.length()%2==1&&num==(1<<(number.length()-1)))return true;
            return false;
        }
    }

Log in to reply
 

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