← All problemsSign in

Small, Smaller, Smallest

CodeChefRating 1403Open on judge ↗

You are given a **binary** string $S$ of length $N$. You can perform the following two-step operation on it: 1. Choose a non-empty contiguous substring of $S$. 2. If the substring contains an odd number of ones, delete every $0$ in it. If it instead contains an even number of ones, delete every $1$ in it. For example, suppose $S = \texttt{1010001}$, - If you choose the substring $\texttt{101}

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