@@ -0,0 +1,843 @@
+# Time:  O(1)%0A# Space: O(1)%0A%0A# Given a positive integer, check whether it has alternating bits:%0A# namely, if two adjacent bits will always have different values.%0A#%0A# Example 1:%0A# Input: 5%0A# Output: True%0A# Explanation:%0A# The binary representation of 5 is: 101%0A#%0A# Example 2:%0A# Input: 7%0A# Output: False%0A# Explanation:%0A# The binary representation of 7 is: 111.%0A#%0A# Example 3:%0A# Input: 11%0A# Output: False%0A# Explanation:%0A# The binary representation of 11 is: 1011.%0A#%0A# Example 4:%0A# Input: 10%0A# Output: True%0A# Explanation:%0A# The binary representation of 10 is: 1010.%0A    %0Aclass Solution(object):%0A    def hasAlternatingBits(self, n):%0A        %22%22%22%0A        :type n: int%0A        :rtype: bool%0A        %22%22%22%0A        n, curr = divmod(n, 2)%0A        while n %3E 0:%0A            if curr == n %25 2: return False%0A            n, curr = divmod(n, 2)%0A        return True%0A

Create binary-number-with-alternating-bits.py