Power of Two
Given an integer, write a function to determine if it is a power of two.
class Solution {
public:
bool isPowerOfTwo(int n) {
if (n <= 0)
{
return false;
}
return (n > 0 && 0 == (n & (n-1)) ) ? true : false;
}
};