bugfree Icon
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course

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...