Given a positive integer n. The task is to check whether this integer has an alternate pattern of 0 and 1 in its binary representation or not. NOTE: Return 1 if the integer has alternate 0 and 1 in its binary representation else return 0.
Input: n = 12
Explanation: n = 12 = "1100"
Hence there is no alternate pattern.
Input: n = 10
Explanation: n = 10 = "1010".
Hence n has an alternate pattern.
You dont need to read input or print anything. Complete the function bitsAreInAltOrder() which takes n as input parameter and returns 1 if the integer has alternate 0 and 1 in its binary representation else return 0.
Expected Time Complexity: O(1) Expected Auxiliary Space: O(1)