Power of 2 Check Problem
Power of 2 Check Problem — ExecCode Easy DSA Practice
Solve the Power of 2 Check problem on ExecCode. Free online easy DSA practice in Numbers & Math Logic. Write and run code in Java, C++, Python — no signup required to run.
Problem description
Description You are given an integer n, return true if it is a power of two. Your task is to otherwise, return false . An integer n is a power of two, if there exists an integer x such that n == 2^x.
Examples
Input {"n": 4}; Output Yes. Input {"n": 5}; Output No. Input {"n": 16}; Output Yes
Constraints
-2^31 <= n <= 2^31 - 1
Practice Power of 2 Check free on ExecCode. Browse DSA problems, topic map, and placement guides.