number. Write it in binary and look at every pair of **neighbouring** ones, meaning ones with only zeros (or nothing) between them. Their distance is the difference of their positions: in 1001, for example, the ones are 3 apart.
Return the largest such distance. If the binary form has just one 1, return 0.number=41 → 3
41 in binary is 101001. Neighbouring ones are 2 and 3 positions apart, and the largest is 3.
number=16 → 0
16 is 10000 with a single one, so there is no pair and the answer is 0.
number=7 → 1
7 is 111, all ones sit side by side, so the distance is 1.
number ≤ 10⁹number=41
3
Run checks the first 3 tests in your browser. Submit checks all 52 tests on the server, hidden ones included.