Shrink It!
CodeChefOpen on judge ↗
*We wanted to give a story, but we have no ideas.* You are given a binary string $s$ of length $N$, a string that contains only $0$s and $1$s. Let us define a contraction operation as the following: Select some $i$, $1\leq i < s.\text{size}$ such that $s[i]=s[i+1]$, remove both of them and replace them with just $s[i]$. Note that this operation reduces the size of the string by $1$. For exampl
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