← All problemsSign in

Non Zero Subarray Xor

CodeChefRating 2101Open on judge ↗

JJ is back with another challenge. He challenges you to construct an array $A$ containing $N$ integers such that the following conditions hold: - For all $1 \le i \le N$, $1 \le A_i \le 10^6$ - Every [subarray](https://stackoverflow.com/a/45686639) has non-zero XOR. That is, for every $1 \le L \le R \le N$, $A_L \oplus A_{L+1} \oplus \ldots \oplus A_R \ne 0$. Here, $\oplus$ denotes the [bitwise XO

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