原题链接:Leetcode 231. 2 的幂
class Solution {
public:
bool isPowerOfTwo(int n) {
//return n>0 && (n&(n-1))==0;
return n>0 && (n&(-n))==n;
}
};
原题链接:Leetcode 231. 2 的幂
class Solution {
public:
bool isPowerOfTwo(int n) {
//return n>0 && (n&(n-1))==0;
return n>0 && (n&(-n))==n;
}
};