← All problemsSign in

XOR Sorting

CodeChefRating 1770Open on judge ↗

For an array $A$ of length $N$, we define $f(A)$ to be the smallest non-negative integer $K$ such that $A$ can be sorted in ascending order by using the following operation several (possibly, zero) times: - Choose an index $i$ ($1 \le i \lt N$) such that $A_i \oplus A_{i+1} \le K$. - Then, swap $A_i$ with $A_{i+1}$. Here, $\oplus$ denotes the bitwise XOR operation. --- You're given two integers

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