Exit Door
There are $N$ people sitting in a single row inside a movie theatre. Each person has a unique number from $1$ to $N$, representing their *priority* or *importance*. You are given a **permutation** $P_1, P_2, \ldots, P_N$ where $P_i$ is the number of the person sitting in the $i^{th}$ seat (from left to right). After the movie ends, people start leaving the hall **one by one** — in order of **
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