Skip to content

Instantly share code, notes, and snippets.

@josephbima
Last active January 27, 2026 03:30
Show Gist options
  • Select an option

  • Save josephbima/4e0e6311a23c47ad65fff67774edb11a to your computer and use it in GitHub Desktop.

Select an option

Save josephbima/4e0e6311a23c47ad65fff67774edb11a to your computer and use it in GitHub Desktop.

At Moflip, we manage massive live events. Imagine we have a stadium with $n$ seats, numbered from 1 to $n$. All seats are initially unreserved. We need to implement a SeatManager class that efficiently handles the reservation and cancellation of these seats in real-time.

Requirements:

  1. SeatManager(int n): Initializes a SeatManager object that will manage $n$ seats numbered from 1 to $n$.
  2. reserve(): Fetches the smallest-numbered unreserved seat, reserves it, and returns its number.
  3. unreserve(int seatNumber): Unreserves the seat with the given seatNumber.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment