Java one-line Solution by bit operation


  • 1
    Q

    public class Solution {

    public boolean isPowerOfFour(int num) {
       return (num >0 && Integer.bitCount(num) == 1 && ((num & 0xAAAAAAAA) == 0));
    }
    

    }


Log in to reply
 

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