//#231 Power of Two
//8ms 98.07%
class Solution {
public:
bool isPowerOfTwo(int n)
{
int m = n & (n-1);
return ( (n > 0) && (m == 0) );
}
};
[Leetcode]#231 Power of Two
最新推荐文章于 2024-11-17 18:49:52 发布
//#231 Power of Two
//8ms 98.07%
class Solution {
public:
bool isPowerOfTwo(int n)
{
int m = n & (n-1);
return ( (n > 0) && (m == 0) );
}
};