Skip to content

Instantly share code, notes, and snippets.

@atul-chaudhary
Created September 24, 2019 09:27
Show Gist options
  • Save atul-chaudhary/098bfe6761524a09b5bd88ca91a006c2 to your computer and use it in GitHub Desktop.
Save atul-chaudhary/098bfe6761524a09b5bd88ca91a006c2 to your computer and use it in GitHub Desktop.
leetcode:693
class Solution:
def hasAlternatingBits(self, n: int) -> bool:
st=''
while(n>0):
st+=str(n%2)
n=n//2
for i in range(len(st)-1):
if(st[i]==st[i+1]):
return False
else:
return True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment