Math Fundamentals18 sections · 814 units
Open in Course

Practice - Power of Three

(LeetCode 326)

Given an integer n, return true if it is a power of three. Use the same technique as Power of Two but with mod 3.

Alternatively, use a logarithm trick or precompute all powers of 3 that fit in 32 bits.