326. Power of Three ¶ Time: $O(1)$ Space: $O(1)$ C++JavaPython 1 2 3 4 5 6class Solution { public: bool isPowerOfThree(int n) { return n > 0 && static_cast<int>(pow(3, 19)) % n == 0; } }; 1 2 3 4 5class Solution { public boolean isPowerOfThree(int n) { return n > 0 && Math.pow(3, 19) % n == 0; } } 1 2 3class Solution: def isPowerOfThree(self, n: int) -> bool: return n > 0 and 3**19 % n == 0