Skip to content

Practice Power of Two

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Easy#231
LeetCode Problem

Power of Two

Problem Statement

Given an integer n, return true if it is a power of two. Otherwise, return false. An integer n is a power of two, if there exists an integer x such that n == 2^x (2 raised to the power x).

Source: Power of Two on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
n = 1
Output
true

# Example 2

Input
n = 16
Output
true

# Example 3

Input
n = 3
Output
false

Constraints

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

Related LeetCode Problems

Practice more problems similar to Power of Two.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.