Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
Consider trying to solve the problem for each bit position separately.
For each bit position, find the position of the next number that has a 1 in that position, if any.
Take the maximum distance to such a number, including the current number.
Iterate backwards to achieve a linear complexity.