LeetCode "Power of Two"

Just one line. Bit-wise ops:

class Solution {
public:
    bool isPowerOfTwo(int n) 
    {
        return (n > 0) && (n & (n - 1)) == 0;
    }
};
原文地址:https://www.cnblogs.com/tonix/p/4623408.html