Skip to content
Onsite

Power of Two

EasyP2Coding

Given an integer n, return true if there is an integer k >= 0 such that n == 2^k, otherwise false.

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

Hints

Run checks the 3 visible tests, Submit all 10.