← All problemsSign in

Maximal AND

You are given two numbers $A$ and $B$ as input. You can perform the following operation on either $A$ or $B$ only once: Operation: $X = X⊕C $ where $0<C<=X$ and ⊕ is bitwise XOR operation. This means you can XOR any one of **A** and **B** with a number less than or equal to it. Your task is to maximize **A** & **B** (where **&** is bitwise AND) using the above operation atmost once only, with the

HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17

CodeSearch Tutor

Hints, not spoilers — it won’t hand over the full solution unless you insist.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start