Math Fundamentals18 sections · 814 units
Open in Course

Problem - Power of Two

LeetCode 231

Given an integer nn, return true if it is a power of 2, otherwise return false. A number is a power of 2 if there exists an integer xx such that n=2xn = 2^x.

For example, n=16n=16 returns true (24=162^4=16), but n=18n=18 returns false.

You know the trick from the previous unit. Can you implement it?