Skip to content

Instantly share code, notes, and snippets.

At a ticketing company, 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.