Ezvor

3125. Maximum Number That Makes Result of Bitwise AND Zero

MediumString Preparing judge… LeetCode
StringGreedySorting

Hints

Hint 1
Examine the set bits of n.
Hint 2
When performing bitwise AND operations sequentially down from n, the last set bit to turn to 0 identifies the highest set bit.
Hint 3
If the index of the highest set bit is x, the answer is 2x - 1.