Created
September 24, 2019 09:27
-
-
Save atul-chaudhary/098bfe6761524a09b5bd88ca91a006c2 to your computer and use it in GitHub Desktop.
leetcode:693
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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