← All problemsSign in

Friend Groups In A Line

CodeChefRating 2382Open on judge ↗

There are $N$ positions in a queue. Given a *binary string* $S$ of length $N$, where $S_i =$ `'$1$'` denotes, there is a person standing in the $i^{th}$ position. The distance between two people standing in the $i^{th}$ and $j^{th}$ positions respectively in the queue is $\mid i - j \mid$, where $\mid x \mid$ denotes the absolute value of $x$. Now, two people are considered to be friends if they

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