Non Adjacent Flips
You are given a binary string $S$ of length $N$. You can perform the following operation on $S$: - Pick any set of indices such that no two picked indices are adjacent. - Flip the values at the picked indices (i.e. change $0$ to $1$ and $1$ to $0$). For example, consider the string $S = 1101101$. If we pick the indices $\{1,3,6\}$, then after flipping the values at picked indices, we will get
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.
Sign in to chat with the tutor and save your progress.
Sign in to start