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
November 29, 20260
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
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- 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 ProblemsSample Answer
Requirements
hold(seats, user, now): succeeds only if every seat is unsold and either free or already held by this user; sets expiry tonow + 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...