a and b. Write both in binary, aligned at the lowest bit (missing high bits count as zeros).
Return the number of positions where the bits of a and b differ.a=5, b=12 → 2
5 = 0101 and 12 = 1100: the bits differ in the highest and the lowest position, 2 in total.
a=9, b=9 → 0
The numbers are equal, so every bit matches.
a=0, b=255 → 8
a, b ≤ 2³¹ − 1a=5, b=12
2
Run checks the first 3 tests in your browser. Submit checks all 86 tests on the server, hidden ones included.