Design a Fair Event Registration Queue with Capacity and Waitlist

Quick Overview

Design an in-memory event registration service where each event has a fixed capacity, extra users join a first-come, first-served waitlist, and a cancellation promotes the next waiting user. It tests data structure choices for constant-time membership, FIFO order and removal from the middle of a queue.

Design a Fair Event Registration Queue with Capacity and Waitlist

Company: Bloomberg

Role: Software Engineer

Category: Software Engineering Fundamentals

Difficulty: medium

Interview Round: Other

Design an in-memory event registration service that manages user signups for events with strict fairness: users are served in the exact order they registered (first-come, first-served). Each event has a fixed capacity. Users who register while seats remain are placed in the confirmed list; once capacity is reached, additional users join a waitlist. When a confirmed user cancels, the next waitlisted user (if any) is automatically promoted to confirmed. All operations must run efficiently and preserve registration order so that no user can be unfairly skipped. Implement a class `FairEventRegistrationQueue` with the following methods: - `createEvent(eventId: int, capacity: int) -> bool`: Create a new event with the given capacity. Returns `True` on success, `False` if an event with the same id already exists. - `register(eventId: int, userId: int) -> str`: Register a user for an event. Returns `'CONFIRMED'` if a seat was available, `'WAITLISTED'` if added to the waitlist, or `'REJECTED'` if the event does not exist or the user is already registered (confirmed or waitlisted) for it. - `cancel(eventId: int, userId: int) -> bool`: Cancel a user's registration. If the user was confirmed, the next waitlisted user is promoted. Returns `True` if the cancellation succeeded, `False` otherwise. - `getStatus(eventId: int, userId: int) -> str`: Return the user's current status: `'CONFIRMED'`, `'WAITLISTED'`, or `'NONE'` if not registered or the event does not exist. - `getConfirmedCount(eventId: int) -> int`: Return the number of confirmed registrations for the event. Returns 0 if the event does not exist. Example 1: ```text Input: ["FairEventRegistrationQueue", "createEvent", "createEvent", "register", "register", "cancel", "getStatus", "register", "getStatus"] [[], [5, 1], [5, 3], [5, 7], [9, 7], [5, 7], [5, 7], [5, 8], [5, 8]] Output: [null, true, false, "CONFIRMED", "REJECTED", true, "NONE", "CONFIRMED", "CONFIRMED"] ``` Event 5 is created with one seat, and the second `createEvent(5, 3)` fails and leaves that capacity unchanged. User 7 takes the only seat, and registering for event 9 is rejected because that event does not exist. After user 7 cancels, their status is `'NONE'`, and user 8 gets the freed seat. Example 2: ```text Input: ["FairEventRegistrationQueue", "createEvent", "register", "register", "register", "register", "register", "cancel", "getStatus", "getStatus", "cancel", "getConfirmedCount", "cancel"] [[], [1, 2], [1, 10], [1, 11], [1, 12], [1, 13], [1, 12], [1, 10], [1, 12], [1, 13], [1, 13], [1], [1, 13]] Output: [null, true, "CONFIRMED", "CONFIRMED", "WAITLISTED", "WAITLISTED", "REJECTED", true, "CONFIRMED", "WAITLISTED", true, 2, false] ``` Event 1 has two seats. Users 10 and 11 fill them, and users 12 and 13 join the waitlist in that order. User 12 registering again is rejected because they are already waitlisted. When user 10 cancels, user 12 (the earliest waitlisted user) is promoted, so 12 is confirmed and 13 is still waiting. User 13 then cancels from the waitlist, which frees no seat, so the confirmed count stays 2. A second cancel by user 13 returns `False` because they are no longer registered. ```hint List the waitlist operations Write down every way the waitlist changes: a user joins at the back, the earliest user leaves on promotion, and a waitlisted user cancels from anywhere in the line. Pick a structure where all three are cheap; a plain list or deque makes at least one of them linear. ``` ```hint Look for an invariant Ask whether a new registrant can ever be confirmed while someone is still on the waitlist. State the invariant that rules this out and check that every method preserves it. ``` ### Constraints & Assumptions - `1 <= capacity <= 10^5` - `1 <= eventId, userId <= 10^9` - At most `10^5` method calls are made in total. - A `userId` identifies one user. A `register` call for a user who is already confirmed or waitlisted for that event returns `'REJECTED'` and does not change their place. - The service is in memory and runs in a single process. ### Clarifying Questions to Ask - If a user cancels and later registers again for the same event, is that a new registration at the back of the line, or do they get their old place back? - Does cancelling a waitlisted user count as a successful cancellation, and should it promote anyone? - Can an event's capacity change, or an event be deleted, after it is created? - Will calls arrive concurrently from several threads, or is the service single-threaded? ### What a Strong Answer Covers - A per-event data structure choice for the confirmed users and the waitlist, with the cost of append, promotion, mid-line removal and membership checks stated. - An argument that the order stays fair: nobody who registered later gets a seat ahead of someone still waiting. - Every return value in the spec, including missing events, duplicate events, duplicate registrations and repeated cancels. - What happens when a user cancels and registers again. - Time and space complexity for each method. ### Follow-up Questions - How would you make the service thread-safe so two concurrent registrations can never overbook an event, without serializing calls for unrelated events? - How would you add `getWaitlistPosition(eventId, userId)`, and what would each call cost? - How would the design change if a promoted user had to accept the seat within a time window before it passed to the next person in line? - How would you keep the registration order across a process restart?

Overview: Design an in-memory event registration service where each event has a fixed capacity, extra users join a first-come, first-served waitlist, and a cancellation promotes the next waiting user. It tests data structure choices for constant-time membership, FIFO order and removal from the middle of a queue.

Bloomberg logo
Bloomberg
Nov 25, 2026
mediumSoftware EngineerOtherSoftware Engineering Fundamentals
0
0

Design an in-memory event registration service that manages user signups for events with strict fairness: users are served in the exact order they registered (first-come, first-served).

Each event has a fixed capacity. Users who register while seats remain are placed in the confirmed list; once capacity is reached, additional users join a waitlist. When a confirmed user cancels, the next waitlisted user (if any) is automatically promoted to confirmed.

All operations must run efficiently and preserve registration order so that no user can be unfairly skipped.

Implement a class FairEventRegistrationQueue with the following methods:

  • createEvent(eventId: int, capacity: int) -> bool : Create a new event with the given capacity. Returns True on success, False if an event with the same id already exists.
  • register(eventId: int, userId: int) -> str : Register a user for an event. Returns 'CONFIRMED' if a seat was available, 'WAITLISTED' if added to the waitlist, or 'REJECTED' if the event does not exist or the user is already registered (confirmed or waitlisted) for it.
  • cancel(eventId: int, userId: int) -> bool : Cancel a user's registration. If the user was confirmed, the next waitlisted user is promoted. Returns True if the cancellation succeeded, False otherwise.
  • getStatus(eventId: int, userId: int) -> str : Return the user's current status: 'CONFIRMED' , 'WAITLISTED' , or 'NONE' if not registered or the event does not exist.
  • getConfirmedCount(eventId: int) -> int : Return the number of confirmed registrations for the event. Returns 0 if the event does not exist.

Example 1:

Input:
["FairEventRegistrationQueue", "createEvent", "createEvent", "register", "register", "cancel", "getStatus", "register", "getStatus"]
[[], [5, 1], [5, 3], [5, 7], [9, 7], [5, 7], [5, 7], [5, 8], [5, 8]]

Output: [null, true, false, "CONFIRMED", "REJECTED", true, "NONE", "CONFIRMED", "CONFIRMED"]

Event 5 is created with one seat, and the second createEvent(5, 3) fails and leaves that capacity unchanged. User 7 takes the only seat, and registering for event 9 is rejected because that event does not exist. After user 7 cancels, their status is 'NONE', and user 8 gets the freed seat.

Example 2:

Input:
["FairEventRegistrationQueue", "createEvent", "register", "register", "register", "register", "register", "cancel", "getStatus", "getStatus", "cancel", "getConfirmedCount", "cancel"]
[[], [1, 2], [1, 10], [1, 11], [1, 12], [1, 13], [1, 12], [1, 10], [1, 12], [1, 13], [1, 13], [1], [1, 13]]

Output: [null, true, "CONFIRMED", "CONFIRMED", "WAITLISTED", "WAITLISTED", "REJECTED", true, "CONFIRMED", "WAITLISTED", true, 2, false]

Event 1 has two seats. Users 10 and 11 fill them, and users 12 and 13 join the waitlist in that order. User 12 registering again is rejected because they are already waitlisted. When user 10 cancels, user 12 (the earliest waitlisted user) is promoted, so 12 is confirmed and 13 is still waiting. User 13 then cancels from the waitlist, which frees no seat, so the confirmed count stays 2. A second cancel by user 13 returns False because they are no longer registered.

Constraints & Assumptions

  • 1 <= capacity <= 10^5
  • 1 <= eventId, userId <= 10^9
  • At most 10^5 method calls are made in total.
  • A userId identifies one user. A register call for a user who is already confirmed or waitlisted for that event returns 'REJECTED' and does not change their place.
  • The service is in memory and runs in a single process.

Clarifying Questions to Ask Guidance

  • If a user cancels and later registers again for the same event, is that a new registration at the back of the line, or do they get their old place back?
  • Does cancelling a waitlisted user count as a successful cancellation, and should it promote anyone?
  • Can an event's capacity change, or an event be deleted, after it is created?
  • Will calls arrive concurrently from several threads, or is the service single-threaded?

What a Strong Answer Covers Guidance

  • A per-event data structure choice for the confirmed users and the waitlist, with the cost of append, promotion, mid-line removal and membership checks stated.
  • An argument that the order stays fair: nobody who registered later gets a seat ahead of someone still waiting.
  • Every return value in the spec, including missing events, duplicate events, duplicate registrations and repeated cancels.
  • What happens when a user cancels and registers again.
  • Time and space complexity for each method.

Follow-up Questions Guidance

  • How would you make the service thread-safe so two concurrent registrations can never overbook an event, without serializing calls for unrelated events?
  • How would you add getWaitlistPosition(eventId, userId) , and what would each call cost?
  • How would the design change if a promoted user had to accept the seat within a time window before it passed to the next person in line?
  • How would you keep the registration order across a process restart?