关键函数lowbit:
x&(-x)
class Solution {
public:
bool isPowerOfTwo(int n) {
long long t = n;
if(t == 0) return false;
return (t & (-t)) == t;
}
};
关键函数lowbit:
x&(-x)
class Solution {
public:
bool isPowerOfTwo(int n) {
long long t = n;
if(t == 0) return false;
return (t & (-t)) == t;
}
};