FunctionRacerProblemsRace

Minimum Bit Flips

EasyBitsPython, JavaScript, TypeScript, Java, C++

In one move you may flip a single bit (0 to 1 or 1 to 0) in the binary form of the number. Return the fewest moves needed to turn start into goal.

Example 1

start 10
goal 7
returns 3

1010 to 0111 needs 3 flips.

Example 2

start 3
goal 4
returns 3

011 to 100 needs 3 flips.

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