Seat Hold Manager With Expiring Checkout Reservations

Last updated: November 29, 2026

Quick Overview

Implement a class that lets a user place a time-limited hold on a set of seats during checkout, purchase seats they hold, and query availability, with holds expiring automatically after a fixed TTL.

StubHub
Coding & Algorithms
Software Engineer
StubHub
November 29, 2026
Software Engineer
Onsite
Coding & Algorithms
Medium

0

0

0 solved


Implement a class that lets a user place a time-limited hold on a set of seats during checkout, purchase seats they hold, and query availability, with holds expiring automatically after a fixed TTL.

When a StubHub buyer clicks into checkout, the tickets are reserved for a few minutes so nobody else can buy them mid-payment. This onsite coding round checks object design, all-or-nothing semantics on multi-seat holds, and an efficient expiry strategy rather than scanning every hold on every call.

What the Interviewer Expects
  • Makes hold and purchase all-or-nothing across the requested seats
  • Lets the same user refresh their own hold
  • Expires holds lazily with a min-heap keyed by expiry time
  • Handles stale heap entries left behind by refreshed holds
  • Explains the time complexity of each operation
Key Topics to Cover
object-oriented design
heaps
TTL expiry
inventory reservation
atomicity
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • How would this work across many app servers instead of one process?
  • What should happen if payment authorisation succeeds one second after the hold expired?
  • How would you cap the number of seats one user can hold at once to stop bots from sitting on inventory?
  • How would you emit an event when a hold expires so the seat map updates for other buyers?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements
  • hold(seats, user, now): succeeds only if every seat is unsold and either free or already held by this user; sets expiry to now + ttl.
  • purchase(seats, user, now): succeeds only if this user h...
High-Level Design

State: holds maps seat to (user, expires_at), sold is a set, and a min-heap stores (expires_at, seat). Every public call first pops heap entries whose expiry is at or before now. Because a r...


Submit Your Answer
Markdown supported

Related Questions