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.
Description Given a positive integer, check whether it has alternating bits: namely, if two adjacent bits will always have different values. Examples Example 1 Input: n = 5 Output: true Explanation: The binary representation of 5 is: 101 Example 2 Input: n = 7 Output: false Expl…
Practice Binary Number with Alternating Bits free on ExecCode. Browse more ExecCode DSA problems.