Skip to content

Latest commit

 

History

History
23 lines (14 loc) · 342 Bytes

693.md

File metadata and controls

23 lines (14 loc) · 342 Bytes

Binary Number with Alternating Bits

Description

link


Solution

  • bin in python

Code

O(1)

class Solution:
    def hasAlternatingBits(self, n: int) -> bool:
        return '00' not in bin(n) and '11' not in bin(n)