Skip to content

Latest commit

 

History

History
39 lines (28 loc) · 958 Bytes

_231. Power of Two.md

File metadata and controls

39 lines (28 loc) · 958 Bytes

All prompts are owned by LeetCode. To view the prompt, click the title link above.

Back to top


First completed : March 04, 2025

Last updated : March 04, 2025


Related Topics : Math, Bit Manipulation, Recursion

Acceptance Rate : 48.22 %


Solutions

Python

class Solution:
    def isPowerOfTwo(self, n: int) -> bool:
        return n > 0 and bin(n).count('1') == 1
class Solution:
    def isPowerOfTwo(self, n: int) -> bool:
        return n >= 1 and (n == 1 or n // 2 * 2 == n and self.isPowerOfTwo(n // 2))