Problem
A theatre has n seats numbered 1 to n, all free at the start. Build a class SeatManager:
- SeatManager(n) sets up the n seats.
- reserve() books the smallest-numbered free seat and returns its number.
- unreserve(seat_number) (seatNumber in TypeScript) frees that seat again.
Example 1
m = SeatManager(5)
Example 2
- Input
- m.reserve()
- Output
- 1
Example 3
- Input
- m.reserve()
- Output
- 2
Example 4
m.unreserve(2)
Example 5
- Input
- m.reserve()
- Output
- 2
Example 6
- Input
- m.reserve()
- Output
- 3
Constraints
1 <= n <= 10^5At most 10^5 calls are made in total.reserve is only called when at least one seat is free.unreserve is only called on a seat that is currently reserved.