← All problemsSign in

Counting is life

You are given a set $S$ of $K$ numbers which is a set of first $K$ powers of $2$ (ie. $1$,$2$,$4$,$8$,...) Given $N$ you have to construct an Array $A$[$0$, ..., $N-1$] of length $N$ such that $A[i]$ must belong to $S$ for all $i$, $0$ <= $i$ < $N$. Find the maximum value of $A[0]$ XOR $A[1]$ XOR ... XOR $A[N-1]$ that you can achieve. Here XOR is bitwise xor operator. Also, tell the number of a

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