855 Exam Room
855. Exam Room
1. Question
Input: ["ExamRoom","seat","seat","seat","seat","leave","seat"],
[[10],[],[],[],[],[4],[]]
Output:
[null,0,9,4,2,null,5]
Explanation:
ExamRoom(10) -> null
seat() -> 0, no one is in the room, then the student sits at seat number 0.
seat() -> 9, the student sits at the last seat number 9.
seat() -> 4, the student sits at the last seat number 4.
seat() -> 2, the student sits at the last seat number 2.
leave(4) -> null
seat() -> 5, the student sits at the last seat number 5.2. Implementation
3. Time & Space Complexity
Last updated