Given a positive integer n, return true if it is a power of two, or false otherwise. Solve this using bit manipulation.
A number is a power of two if it can be expressed as 2^k for some non-negative integer k. In binary, powers of two have exactly one 1-bit (e.g., 1 = 1, 2 = 10, 4 = 100, 8 = 1000).
n = 16truen = 1truen = 6false1 <= n <= 2^31 - 1Run your code to see results
Use Cmd+Enter to run