PIXELBANKv9.1.0
Menu

Given an integer n, return True if it is a power of two.

Example:

Input:
16
Output:
True
Reasoning:
  • The input 16 is analyzed to determine if it is a power of two.
  • We can express 16 as 242^4, which means it can be represented as a power of two.
  • To verify this, we can use the property that all powers of two have exactly one bit set to 1 in their binary representation: 16 in binary is 10000, which meets this condition.
  • Since 16 satisfies the condition of being a power of two, the function returns True.

Constraints:

  • -2^31 <= n <= 2^31 - 1
🔒

Editor locked

The code editor is locked for Pro problems. It is only available for free problems. Please upgrade to gain access to the code editor for all problems.

solution.py

Test Results

0/0
Run code to see test results.
Power of Two - Easy | PixelBank