Leetcode Problem 1845. Seat Reservation Manager

1845. Seat Reservation Manager

Leetcode Solutions

Approach: Min Heap

  1. Initialize a min-heap to store available seat numbers.
  2. When reserve() is called, pop the root of the heap and return it as the reserved seat number.
  3. When unreserve(seatNumber) is called, push seatNumber back into the heap.
UML Thumbnail

Approach: Sorted/Ordered Set

Ask Question

Programming Language
image/screenshot of info(optional)
Full Screen
Loading...

Suggested Answer

Answer
Full Screen
Copy Answer Code
Loading...