326. Power of Three; 231. Power of Two; 342. Power of Four
326. Power of Three; 231. Power of Two; 342. Power of Four
Given an integer, write a function to determine if it is a power of three.
Example 1:
Input: 27
Output: true
- Base conversion
public boolean isPowerOfThree(int n) {
return Integer.toString(n, 3).matches("^10*$");
}