Problem 3125 · Medium

Maximum Number That Makes Result of Bitwise AND Zero

Find the largest x below n whose set bits never overlap n’s set bits, by filling every open bit of n below its top bit.

Open the interactive visualisation