Alternating String
A binary string is called *alternating* if no two adjacent characters of the string are equal. Formally, a binary string $T$ of length $M$ is called alternating if $T_i \neq T_{i +1}$ for each $1 \leq i \lt M$. For example, `0`, `1`, `01`, `10`, `101`, `010`, `1010` are alternating strings while `11`, `001`, `1110` are not. You are given a binary string $S$ of length $N$. You would like to rear
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