Given an integer n, determine whether it belongs to the sequence of numbers formed by repeatedly multiplying 3 (i.e., 1, 3, 9, 27, 81, …).
Return true if n can be represented as 3^x for some integer x.
Otherwise, return false.
A valid power of three must be positive and must exactly match some exponent of 3.
Input: n = 81
Output: true
Explanation:
81 is equal to 3⁴.
Input: n = 10
Output: false
Explanation:
10 is not any power of 3.
Input: n = 1
Output: true
Explanation:
1 = 3⁰.
Accepted:
Submission: