1 line Java solution, using Integer.


  • 0
    public class Solution {
        public boolean isPowerOfFour(int num) {
            return Integer.bitCount(num)==1 && Integer.numberOfTrailingZeros(num)%2==0;
        }
    }

Log in to reply
 

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