Build A Console Train Ticket Booking System With RAC And Waitlist

Last updated: November 29, 2026

Quick Overview

Implement a small train reservation program that books passengers onto lower, middle and upper berths with a preference, falls back to RAC and then a waitlist when berths run out, and on cancellation promotes RAC to a confirmed berth and the first waitlisted passenger to RAC.

Zoho
Software Engineering Fundamentals
Software Engineer
Zoho
November 29, 2026
Software Engineer
Onsite
Software Engineering Fundamentals
Medium

0

0

0 solved


Implement a small train reservation program that books passengers onto lower, middle and upper berths with a preference, falls back to RAC and then a waitlist when berths run out, and on cancellation promotes RAC to a confirmed berth and the first waitlisted passenger to RAC.

Zoho's hiring loop is well known for a hands-on round where candidates build a working console application in a couple of hours, and booking systems are a natural fit for that format. The interviewer looks at class design, clean state transitions, and whether promotion on cancellation is correct, more than at clever algorithms.

What the Interviewer Expects
  • Model tickets, berths and queues with clear classes
  • Honour berth preference, then fall back to any free berth
  • Give senior passengers a lower berth when one is free
  • Use FIFO queues for RAC and waitlist and promote in order on cancel
  • Reject bookings cleanly when everything is full
  • Keep the code small enough to finish and demo in the round
Key Topics to Cover
Object-oriented design
Queues
State transitions
Machine coding
How to Approach This
  1. Apply SOLID principles. Single Responsibility makes code testable, Open/Closed makes it extensible.
  2. Choose data structures based on access patterns, not familiarity.
  3. Prefer immutable data and message passing over shared mutable state for concurrency.
  4. Design APIs with RESTful conventions, versioning, meaningful errors, and pagination from day one.
Possible Follow-up Questions
  • How would you add multiple coaches and berth types like side lower?
  • How would you print a chart of current allocations?
  • How would you make booking safe if two counters book at the same time?
  • How would you extend this to bookings spanning only part of the route?
Sharpen Your Skills on Codemia

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

Practice System Design Problems
Sample Answer
Requirements

Fixed berths per type, a small RAC capacity and waitlist capacity. book(name, age, pref) returns a ticket with status CNF, RAC or WL, or None if full. cancel(id) frees resources and promotes. Stat...

High-Level Design

Ticket holds id, passenger data, status and berth. TrainBooking keeps a deque of free berth ids per type, deques for RAC and WL, and a dict of live tickets. Promotion is one chain: freed berth goe...


Submit Your Answer
Markdown supported

Related Questions