https://leetcode.com/problems/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) {
return (n>0) && !(n&(n-1));
}
};
https://leetcode.com/problems/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) {
return (n>0) && !(n&(n-1));
}
};