Power of Two

Easy
Math Math Bit Manipulation

Given an integer n, return true if n is a power of two, otherwise false.

Constraints

-2^31 ≤ n ≤ 2^31 - 1

Examples

Example 1:
Input: 1
Output: true
Example 2:
Input: 16
Output: true

Hints

n & (n-1) == 0 for powers of 2.
▲ Console

Install Talent Arabia

Get instant access to jobs and career tools on your device.