0326. Power of Three
https://leetcode.com/problems/power-of-three
Description
Given an integer n
, return true
if it is a power of three. Otherwise, return false
.
An integer n
is a power of three, if there exists an integer x
such that n == 3x
.
Example 1:
Example 2:
Example 3:
Example 4:
Constraints:
-231 <= n <= 231 - 1
Follow up: Could you solve it without loops/recursion?
ac1: iterative
ac2: trick
3^19 = 1162261467, the biggest number within Integer range. so n must <= 1162261467.
ac3: math
Last updated