← All problemsSign in

Blocks in a String

CodeChefRating 2519Open on judge ↗

Define a **block** of a binary string to be a maximal substring consisting of the same character. For example, the blocks of $\text{1100100}$ are $\text{11}$, $\text{00}$, $\text{1}$ and $\text{00}$. You are given a string $S$, of size $N$, consisting of characters $0$, $1$ or $?$. It is guaranteed that $S$ does not begin or end with a $?$, i.e. $S_1 \ne ?$ and $S_N \ne ?$. Your job is to replac

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