← All problemsSign in

Queue

You are standing in a queue with $N$ people in front of you, numbered $1$ to $N$. Person $1$ is at the front of the queue, and person $N$ is towards the back of the queue, and you are behind person $N$. You have to wait for the people in front of you to exit the queue before you can reach the front, which is your goal. You know that the $i$-th person will take exactly $A_i$ units of time to exit

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