dsa · easy

Power of Two

Return whether n is a positive power of two (1, 2, 4, 8, …).

Arguments

Example

n = 16true. n = 3false. n = 1true.

Constraints

-2^31 <= n <= 2^31 - 1 Hidden tests include near-max size for this bound; a slower-than-intended solution TLEs.

Examples

Example 1

Input:
1

Expected:
true

Example 2

Input:
16

Expected:
true

Example 3

Input:
3

Expected:
false

Open in the Dojo editor