Leetcode 342 Solution
This article provides solution to leetcode question 342 (power-of-four)
Access this page by simply typing in "lcs 342" in your browser address bar if you have bunnylol configured.
Leetcode Question Link
https://leetcode.com/problems/power-of-four
Solution
class Solution {
public:
bool isPowerOfFour(int num) {
if (num <= 0)
return false;
if (num & 0xAAAAAAAA)
return false;
return (num & (num - 1)) == 0;
}
};