As reported: Target Sr Software Engineer loop (2026), round 2 (LLD): design Redbus — functional requirements, entities, classes and interfaces (listed, no code), and the user journey of booking a ticket. The round also had one SQL query that needed a join of two tables.
Design the core of a bus ticket booking app like Redbus: travellers search buses between two cities on a date, pick seats on a bus, pay, and get a ticket; bus operators list their buses and trips.
Cover:
- The functional requirements.
- The entities and how they relate.
- The classes and interfaces (signatures are enough; no implementation is required in the round).
- The user journey of a booking, step by step through your classes.
Agree on scope first (for example: cancellations and refunds, seat holds while paying, operator onboarding).
Code runner format: two lines in LeetCode's design format: the method names and their arguments. The harness prints the list of return values (null for the constructor and addTrip). Implement BookingService with this practice scope (now and departure are epoch seconds):
addTrip(tripId, source, destination, date, departure, fare, seatNumbers).search(source, destination, date, now)— one"<tripId> <fare> <free seats>"per matching trip, in the order trips were added.hold(userId, tripId, seatNos, passengers, now)— distinct seat numbers, one passenger per seat. Holds every seat for 600 seconds (held untilnow + 600) or none: returns""if the trip or a seat does not exist, the lists are empty or of different lengths, or a seat is not free. A seat is free when it was never taken, was released, or its hold ended beforenow(heldUntil < now). On success returns the next booking id ("B1","B2", …; failed holds use no id), statusPENDING, amount = fare × seats.confirm(bookingId, now, paymentOk)— only for aPENDINGbooking (elsefalse). A declined payment marks itFAILEDand frees its seats. A paid booking whose seats are no longer all held by it (heldUntil < now, or taken by another booking) is refunded and markedFAILED. Otherwise its seats becomeBOOKED, statusCONFIRMED, resulttrue.cancel(bookingId, now)— only for aCONFIRMEDbooking (else-1): frees its seats, statusCANCELLED, returns the refund — the full amount whendeparture − now ≥ 24 h, half (rounded down) when≥ 6 h, otherwise0.seatState(tripId, seatNo, now)—"FREE","HELD"or"BOOKED"(an ended hold reads"FREE").status(bookingId)— the status,""for an unknown id.
Python uses snake_case (add_trip, seat_state); Go uses Constructor() and exported names (AddTrip, Hold, …).