🚀

End of Year Sale: Use Coupon Code END2025 to Get Extra 25% Off.

02DAYS
:
07HOURS
:
17MINUTES
:
10SECONDS

Leetcode Problem 342. Power of Four

342. Power of Four

Leetcode Solutions

Bit Manipulation + Math

  1. Check if n is greater than zero, since powers of four are positive.
  2. Check if n is a power of two: n & (n - 1) == 0.
  3. Check if n modulo 3 is equal to 1: n % 3 == 1.
  4. If all the above conditions are met, n is a power of four.
UML Thumbnail

Brute Force + Precomputations

Ask Question

Programming Language
image/screenshot of info(optional)
Full Screen
Loading...

Suggested Answer

Answer
Full Screen
Copy Answer Code
Loading...