← All problemsSign in

XOR Partition Sort

CodeChefRating 3276Open on judge ↗

For an array $B$ of length $M$, consider partitioning the array into $K$ non-intersecting subarrays, and then choosing $K$ integers $X_1, X_2, \ldots, X_K$ and replacing all elements of the $i^{th}$ subarray, say $B_j$ with $B_j \oplus X_i$, where $\oplus$ represents the [bitwise XOR operator](https://en.wikipedia.org/wiki/Bitwise_operation#XOR). Note that $X_i$ can be an **arbitrary** non-negativ

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