Non-Zero XOR
You are given an array $A$ of size $N$. You can rearrange the elements of $A$ as you want. After that, construct an array $B$ of size $N$ as: - $B_1 = A_1$; - $B_i = B_{i - 1} \oplus A_i$ for all $2 \le i \le N$, where $\oplus$ denotes the [bitwise XOR operator](https://en.wikipedia.org/wiki/Bitwise_operation#XOR). Find a rearrangement of $A$ such that $B_i \ne 0$ for all $1 \le i \le N$. ###
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.
Sign in to chat with the tutor and save your progress.
Sign in to start