leetcode-solution icon indicating copy to clipboard operation
leetcode-solution copied to clipboard

Bit operation / Power of Two, bit operation solution

Open yesiah opened this issue 6 years ago • 0 comments

分享一個非常酷炫的位運算解法

bool isPowerOfTwo(int n) {
    return n > 0 && (n & (n - 1)) == 0;
}

yesiah avatar Jul 20 '18 21:07 yesiah