less than 1 minute read

Given an integer n greater than or equal to 0, return whether it is a power of two.

Constraints

  • 0 ≤ n < 2 ** 31

https://binarysearch.com/problems/Check-Power-of-Two

Examples

Example 1

Input

  • n = 2

Output

  • answer = True

Explanation

2^1 = 2

Example 2

Input

  • n = 0

Output

  • answer = False

Example 3

Input

  • n = 1

Output

  • answer = True

Explanation

2^0 = 1

Solution

Leave a comment