Binary Number with Alternating Bits Problem
Binary Number with Alternating Bits Problem — ExecCode Easy DSA Practice
Solve the Binary Number with Alternating Bits problem on ExecCode. Free online easy DSA practice in Bit Manipulation. Write and run code in Java, C++, Python — no signup required to run.
Problem description
Description You are given a positive integer, check whether it has alternating bits: namely, if two adjacent bits will always have different values.
Examples
Input {"n": 5}; Output True. Input {"n": 7}; Output False
Constraints
1 <= n <= 2^31 - 1
Practice Binary Number with Alternating Bits free on ExecCode. Browse DSA problems, topic map, and placement guides.