Power of Two Problem

Power of Two Problem — ExecCode Easy DSA Practice

Solve the Power of Two problem on ExecCode. Free online easy DSA practice in Bit Manipulation. Write and run code in Java, C++, Python — no signup required to run.

Problem description

Given an integer n, return true if it is a power of two, meaning it can be written as 2^x for some non-negative integer x, and false otherwise.

Examples

Input n = 16; Output true. Input n = 3; Output false. Input n = 1; Output true

Constraints

-2^31 <= n <= 2^31 - 1

Practice Power of Two free on ExecCode. Browse DSA problems, topic map, and placement guides.