← All problemsSign in

Make Subarray

CodeChefRating 940Open on judge ↗

There is a canvas with $N$ total cells, and each cell can be painted white or black. Currently, the state of the board can be represented by a binary string $S$, where $S_i = 1$ if and only if the $i$-th call in the canvas is painted black, and $S_i = 0$ otherwise. You want the black cells to form a contiguous subarray, i.e. if cell $x$ and cell $y$ are coloured black, then all cells $z$ between

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