Binary Substitution
Chef has binary string $S$ of length $N$. Chef can perform the following operation on the string: - Choose a contiguous subarray $S_L, S_{L + 1}, \ldots , S_R$ such that the count of set bits in the subarray is **equal** to the count of unset bits in the subarray. - Replace the chosen subarray with either a set bit or an unset bit. Chef wants to reduce the string to **minimum** possible length
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