Power of four solution by Java


  • 0
    1
    class Solution {
        public boolean isPowerOfFour(int num) {
            if(num<=0)   return false;
            int count=0;
            while(count<30)
            {
    
               if(num%4==0)  num/=4;
               count++;
               if(num==1)   return true;
               if(num==0)   return true; 
            }
            return false;
        }
    }
    

Log in to reply
 

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