Working java solution


  • 0
    S
    public class Solution {
        public boolean isPowerOfFour(int num) {
            int digits = Integer.toBinaryString(num).length();
            if(num <= 0 || (digits-1)%2!= 0)
            	return false;
            int r = 1<<(digits-1);
            return (num&(r-1)) == 0;
        }
    }

Log in to reply
 

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