A simple Java solution with loop


  • 2
    A
    public class Solution {
        public boolean isPowerOfFour(int num) {
            while (num>1 && (num&3)==0)
                num>>=2;
            return num==1;
        }
    }
    

Log in to reply
 

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