class Solution {
public boolean isPowerOfTwo(int n) {
// 判断特例
if (n == 0)
return false;
return n > 0 && (n & (n - 1)) == 0;
}
}
LeetCode 231. 2的幂(JAVA)
最新推荐文章于 2021-05-30 13:03:30 发布
class Solution {
public boolean isPowerOfTwo(int n) {
// 判断特例
if (n == 0)
return false;
return n > 0 && (n & (n - 1)) == 0;
}
}