← All problemsSign in

ATM Queue

An entire class of students has gone to the ATM to withdraw cash. Let's name them $\{S_1, S_2, \dots, S_N\}$. Obviously, they have to stand in a queue. They want to do so, such that close friends are standing not too far from each other. Specifically, if $S_i$ and $S_j$ are close friends, then there should not be more than 2 other students standing in between them. Given the close-friendship infor

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