Determine whether an integer is an exact power of two.
Given an integer n, return whether it can be written in the form 2^k for some integer k >= 0.
A number is a power of two if it is positive and has exactly one set bit in its binary representation.
n.n is a power of two.true if n is an exact power of two.false.n fits in a standard 32-bit signed integer.n may be non-positive.Example 1
Input
n = 1
Output
true
Explanation
.
Example 2
Input
n = 16
Output
true
Explanation
.
Example 3
Input
n = 3
Output
false
Explanation
3 is not an exact power of two.
Premium problem context
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.