思路 2的倍数的二进制特点是首位为1,则满足 注意最外层的括号不能省。 代码(cpp) class Solution { public: bool isPowerOfTwo(int n) { return n > 0 && (n & (n - 1)) == 0; } };