Permalink
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
12 lines (11 sloc) 258 Bytes
class Solution:
def hasAlternatingBits(self, n):
"""
:type n: int
:rtype: bool
"""
s = bin(n)[2:]
for i in range(len(s) - 1):
if s[i] == s[i+1]:
return False
return True