LeetCode 231. 2的幂 class Solution { public boolean isPowerOfTwo(int n) { return n > 0 && (n & (n-1)) == 0; } } 这里引用评论区Kico大神的解释。