← All problemsSign in

Joint XOR

CodeChefRating 2398Open on judge ↗

Chef has a binary string $S$ of length $N$. Chef wants to find two substrings of **equal** length, such that their [bitwise XOR](https://en.wikipedia.org/wiki/Bitwise_operation#XOR) is **maximised**. Formally, Chef wants to find $L_1, R_1, L_2,$ and $R_2$ such that: - $1 \le L_1 \le R_1 \le N$ and $1 \le L_2 \le R_2 \le N$ - $|R_1 - L_1 + 1| = |R_2 - L_2 + 1|$, that is, the substrings have equal

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