← All problemsSign in

Flip or Compress

CodeChefRating 2639Open on judge ↗

You are given a binary string $S$. You can perform the following operations on $S$: - Flip: Pick an index $i$ $(1 \le i \le |S|)$ and flip the $i$-th character (i.e change $1$ to $0$ or $0$ to $1$). For e.g. $01\underline{1}001 \rightarrow 01\underline{0}001$ - Compress: Pick any non-empty substring consisting of the same character and replace it with a single occurrence of that character. For e.

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