← All problemsSign in

Grouping them right!

Consider an array $A$ of size $N$ which only contains $1s$ and $0s$. Let's define 'Group' as the subarray containing only 0s or only 1s. You are also given two values $x$ and $y$. Your task is to flip the values (from $0$ to $1$ or from $1$ to $0$) in the array such that length of every 'Group' is between $x$ and $y$ (inclusive). But thats not it :p. You are also given another array $B$ of size $N

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