← All problemsSign in

Finding Seats

There are **N** people wanting to seat on a row of **N** seats. The persons and seats are numbered from **1** to **N**. The **N** people are ordered according to who chooses the seats first. In other words, person **1** is the first to seat, followed by person **2**, then person **3**, etc. In addition, the **ith** person has a preferred seat **Si**, a number from **1** to **N**, and a preferred

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