0342.cpp (120B)
1 class Solution { 2 public: 3 bool isPowerOfFour(int n) { return n > 0 && (n & (n - 1)) == 0 && (n - 1) % 3 == 0; } 4 };