188. Power of Two
Easy · Bit Manipulation
Given an integer n, determine whether it is a power of two. A power of two is a number that can be expressed as 2^k where k is a non-negative integer.
For example, 1, 2, 4, 8, 16 are powers of two. Numbers like 3, 5, 6, 7 are not powers of two.
Examples
Example 1 Input: 8 Output: true Explanation: 8 = 2^3, so it is a power of two.
Example 2 Input: 5 Output: false Explanation: 5 cannot be expressed as 2^k for any non-negative integer k.
Constraints
- Standard input/output constraints apply