A slow way to do in java by generate Qua Srting and do String matches


  • 1
    R
    public class Solution {
        public boolean isPowerOfFour(int num) {
           if(num<=0)
                return false;
            return Integer.toString(num,4).matches("10*");
        }
    }
    

Log in to reply
 

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