One line java, 3ms, Please challenge me : )


  • 0
    H
    public class Solution {
    public boolean isPowerOfFour(int n) {
        return (n>0 && Integer.bitCount(n) == 1 && ((Math.log(n)/Math.log(2))%2==0));
    }
    }

  • 0
    R

    Nice solution. The bitCount(n) == 1 here is redundant since it itself implies n>0.


Log in to reply
 

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