One line Java using math.


  • 0
    L
            return (Math.log10(n)/Math.log10(2.0)%1)==0;
        }
    

    Some math I learnt in high school. Although bit operation is more fun.


Log in to reply
 

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