Power of Two

Easy Topics Company Tags

You are 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).

Example 1:

Input: n = 1

Output: true

Explanation: (2^0) is 1.

Example 2:

Input: n = 8

Output: true

Explanation: (2^3) is 8.

Example 3:

Input: n = 12

Output: false

Constraints:



Topics

Company Tags

Please upgrade to NeetCode Pro to view company tags.


Solution 1
||Ln 1, Col 1

n =