Seat Reservation Manager
Medium · Heap & Priority Queue · about 10 minutes
Asked at Amazon, Google, Microsoft, Uber.
Manage the reservations of n seats numbered 1..n, all initially available.
SeatManager(n)creates the manager.reserve()reserves the smallest-numbered available seat and returns its number (always possible).unreserve(seatNumber)makes a reserved seat available again.