LeetCode – Power of Four (Java)
Given an integer (signed 32 bits), write a function to check whether it is a power of 4. Java Solution 1 – Naive Iteration public boolean isPowerOfFour(int num) { while(num>0){ if(num==1){ return true; } if(num%4!=0){ return false; }else{ num=num/4; } } return false; }public boolean isPowerOfFour(int num) { while(num>0){ if(num==1){ return true; } … Read more