Design Movie Ticket Booking (Low-Level Design)
Hold seats for a few minutes, confirm or release them, and never sell one seat twice. Focus: Temporary holds that expire, and seat state.
| Difficulty | MEDIUM |
|---|---|
| Design focus | Temporary holds that expire, and seat state |
| Automated grading | 3 public + 10 hidden tests (13 total) |
| Phase 2 follow-up | Seat prices |
| Language | TypeScript (OOP / Machine Coding) |
Problem statement
Each show has rows A, B, C… and seats numbered from 1, so seats are named like "A1" or "C12".
hold() reserves a set of seats for 10 minutes (600,000 ms). Within that time the hold can be confirmed into a booking or released. After it, the seats are free again and the hold can no longer be confirmed.
Time is passed in as `now` (milliseconds), so tests control the clock.
Functional requirements
- addShow(showId, rows, seatsPerRow).
- hold(showId, userId, seats, now) returns a hold id; it throws if any seat does not exist, is listed twice, or is not FREE. Holding is all or nothing.
- confirm(holdId, now) returns a booking id; it throws if the hold is unknown, released, already confirmed or expired.
- release(holdId); seatStatus(showId, seat, now) is FREE, HELD or BOOKED; availableSeats(showId, now).
Required API & starter interface
Implement the TypeScript class interface below. You can add any helper classes, policies or strategies you need:
type SeatStatus = "FREE" | "HELD" | "BOOKED";
class BookingSystem {
addShow(showId: string, rows: number, seatsPerRow: number): void {
throw new Error("Not implemented");
}
hold(showId: string, userId: string, seats: string[], now: number): string {
throw new Error("Not implemented");
}
confirm(holdId: string, now: number): string {
throw new Error("Not implemented");
}
release(holdId: string): void {
throw new Error("Not implemented");
}
seatStatus(showId: string, seat: string, now: number): SeatStatus {
throw new Error("Not implemented");
}
availableSeats(showId: string, now: number): number {
throw new Error("Not implemented");
}
}
Public test cases
Your code runs against 3 public tests plus 10 hidden edge-case tests in a sandbox:
Hold then confirm
var b = new BookingSystem();
b.addShow("s1", 2, 5);
var h = b.hold("s1", "u1", ["A1", "A2"], 0);
assertEqual(b.seatStatus("s1", "A1", 1), "HELD");
b.confirm(h, 1000);
assertEqual(b.seatStatus("s1", "A1", 2000), "BOOKED");
assertEqual(b.availableSeats("s1", 2000), 8);
A held seat cannot be held again
var b = new BookingSystem();
b.addShow("s1", 1, 3);
b.hold("s1", "u1", ["A1"], 0);
assertThrows(function () { b.hold("s1", "u2", ["A1"], 10); });
Holds expire after 10 minutes
var b = new BookingSystem();
b.addShow("s1", 1, 3);
b.hold("s1", "u1", ["A1"], 0);
assertEqual(b.seatStatus("s1", "A1", 599999), "HELD");
assertEqual(b.seatStatus("s1", "A1", 600000), "FREE");
Design & structure checks
Beyond passing tests, the grader inspects your class structure for clean object-oriented design:
- Seat state is a named type: FREE, HELD and BOOKED are the heart of the problem. A named type makes every transition visible to the compiler.
- A show (or seat map) class owns its seats: Keeping seats inside a show object stops one show's bookings from leaking into another.
Phase 2: Change request
In real interviews, the follow-up tests whether your design is extensible. After your first version passes all 13 tests, you unlock the change request: Seat prices.
Pair with High-Level System Design
Ready to scale Movie Ticket Booking across distributed servers? Try the matching HLD simulator problem: Design Movie Booking System.
Relevant low-level design lessons
From a problem to classes
Turn a problem statement into a first list of classes and methods.
One class, one job
Spot a class that does too much and split it.
Hide state behind methods
Protect an object's rules by keeping its data private.
More low-level design problems
Design Digital Wallet
Deposits, withdrawals and transfers that are safe to retry, with a full history.
Design Calendar Scheduling
Book meetings without double-booking anyone, and find free time for a group.
Design LRU Cache
A fixed-size cache that throws out the least recently used entry when full, with every operation in constant time.
Design Rate Limiter
Two rate-limiting algorithms behind one interface, so callers can swap them.