C# [64 characters]


  • 0
    L

    Not the most efficient, still O(1)

    class Solution{public bool IsPowerOfTwo(int n)=>n>0&(n&--n)==0;}

Log in to reply
 

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