Given an integer n, return true if it is a power of three.

Input: 27 → Output: trueInput: 0 → Output: false

The largest power of 3 that fits in a 32-bit integer is 3^19 = 1162261467. Any n that is a power of 3 must divide this number.

class Solution { public boolean isPowerOfThree(int n) { return n > 0 && 1162261467 % n == 0; } }