FunctionRacerProblemsRace

Alternating Bits

EasyBitsPython, JavaScript, TypeScript, Java, C++

Return True if the binary form of the positive integer n never has two equal bits next to each other (like 10101), otherwise False.

Example 1

n 5
returns true

101 alternates.

Example 2

n 7
returns false

111 does not.

Constraints

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More Bits problems