Recognize Powers of Three without Iteration
Company: Google
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: easy
Interview Round: Other
### Problem
Return whether signed integer n is 3 raised to a nonnegative integer power.
```cpp
bool isPowerOfThree(int n);
```
### Examples
```text
n = 81 -> true
n = 45 -> false
```
### Constraints
- n spans the signed 32-bit domain.
### Optional follow-up
Can you solve it without loops or recursion?
Overview: Recognize Powers of Three without Iteration. Return whether signed integer n is 3 raised to a nonnegative integer power.