← All problemsSign in

Beautiful Flip

CodeChefRating 2616Open on judge ↗

Define the *beauty* of a **binary** string to be the minimum of the number of zeros and the number of ones present in it. For example, the beauty of $\texttt{111}$ is $0$, while the beauty of $\texttt{1001100}$ is $3$. You are given a binary string $S$ of length $N$, along with an integer $K$. At most once, you can do the following: - Choose a substring of $S$ of length **at most** $K$, and

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