N people queue for seats: each takes the wanted seat if it is free, otherwise wants the next seat number and rejoins the back of the queue. Return everyone's final seat.
Unlock detailed company stats for this questionUpgrade
N people stand in a queue, and person i wants seat arr[i], a value from 1 to N. People are taken in queue order. If the wanted seat is free, the person sits there. Otherwise the person increases the wanted seat number by one and moves to the back of the queue. Seat numbers above N are allowed. Return the seat each person ends up in, with a solution that stays fast for large N.
Community answers
No answers contributed by the community yet.
Related courses

Course
