Google Interview QuestionInterns
- 0of 0 votes
You are in charge of a classroom which has n seats in a single row, numbered 0 through n-1.
During the day students enter and leave the classroom for the exam.
In order to minimize the cheating, your task is to efficiently seat all incoming students.
You're given 2 types of queries: add_student(student_id) -> seat index, and remove_student(student_id) -> void.
The rules for seating the student is the following:
1) The seat must be unoccupied
2) The closest student must be as far away as possible
3) Ties can be resolved by choosing the lowest-numbered seat.
Country: United States