Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
Examine the set bits of <code>n</code>.
When performing bitwise AND operations sequentially down from <code>n</code>, the last set bit to turn to 0 identifies the highest set bit.
If the index of the highest set bit is <code>x</code>, the answer is <code>2<sup>x</sup> - 1</code>.