solidcodersolidcoder
Explore Courses
solidcodersolidcoder

Practical courses for software engineering interviews — no gatekeeping, no fluff.

Company-wise Questions

  • Flipkart Machine Coding Questions
  • Swiggy Machine Coding Questions
  • Meesho Machine Coding Questions

Machine Coding Tutorial

  • Machine Coding Tutorial

Explore

  • Courses
  • About
  • Privacy Policy
  • Terms

© 2026 solidcoder · Practical courses for software engineering interviews.

Built for the AI era — learn by doing.

Home/Machine Coding/Meesho Machine Coding Questions/Gym Chain Booking Portal
Chapters — Meesho Machine Coding Questions▾

Gym Chain Booking Portal

Machine Coding·SDE-3+·5 min read·Sep 11, 2026

Design an online booking portal for an offline gym chain — admin gym/class management and customer bookings, with concurrency-safe capacity limits.

Asked inMeesho

An existing gym chain that's completely offline wants to start an online portal for managing bookings. The portal has two views: an admin view for managing gyms and classes, and a customer view for booking into them.

What the round tests

This one tests whether you can enforce capacity limits correctly at two nested levels — a gym's overall max accommodation and each class's own max limit — while keeping bookings thread-safe under concurrent customers competing for the same class slot.

Objective

The primary objective of this project is to design and implement an in-memory gym booking system as a plain Java driver-class program, where admins manage gyms and classes within capacity constraints, and customers book, view, and cancel their own class bookings safely under concurrency.

Functional Requirements

Two views, one system

Requirements split naturally along the two portal views: what an admin can do, and what a customer can do. Both act on the same underlying gym/class/booking state, so capacity checks and concurrency matter across both.

Part 1 — Admin Flows

Admin operations
Operation
Behavior
add_gym(name, location, max_accomodation)
Creates a gym. max_accomodation is the maximum number of people allowed in that gym at any given point in time. Each gym can run multiple classes between 6am and 8pm.
remove_gym(gym_id)
Removes the entire gym, which also cancels every class hosted there and every booking against those classes.
addClass(gym_id, class_type, max_limit, start_time, end_time)
Creates a class within a gym. max_limit is the maximum number of people in that class. class_type describes the workout (e.g. weights, cardio). The gym's max_accomodation must be checked/respected at class creation time.
removeClass(gym_id, class_id)
Removes a single class from a gym.

Part 2 — Customer Flows

Customer operations
Operation
Behavior
bookClass(customer_id, gym_id, class_id)
Books a customer into a class, only if the class isn't already at its max_limit. A given customer can book a given class only once.
getAllBookings(customer_id)
Returns every booking made by that customer.
cancelBooking(booking_id)
Cancels an existing booking.
Capacity & uniqueness rules

A class's max_limit counts toward its gym's overall max_accomodation, and that accommodation limit must be validated at class-creation time, not just at booking time. Each customer may hold at most one booking per class — a repeat bookClass call for the same customer and class should be rejected.

Example Usage

The source problem gives a short example chain of calls; here it is, extended slightly to exercise cancellation and lookup as well.

1. Create a gym

addGym("Gym1", "Indira Nagar", 100)
→ Success: returns gym1_id

2. Create a class within the gym

addClass("gym1_id", "cardio", 20, "6:00", "7:00")
→ Success: returns class1_id

3. Book a customer into the class

bookClass("customer1", "gym1_id", "class1_id")
→ Success: returns booking1_id

4. View the customer's bookings

getAllBookings("customer1")
→ [ { bookingId: "booking1_id", gymId: "gym1_id", classId: "class1_id" } ]

5. Cancel the booking

cancelBooking("booking1_id")
→ Success: booking1_id canceled
Result

The chain of calls shows the full lifecycle for one customer: a gym and class are created within capacity limits, the customer books successfully and can retrieve that booking, and cancelling it removes it cleanly without affecting the gym or class themselves.

Guidelines

Constraints & assumptions

Use in-memory data structures only — no databases. Handle exceptions gracefully, and handle concurrency and race conditions explicitly (this is directly evaluated). Do not implement authentication. Write plain Java with a driver class to demonstrate the solution — no frameworks like Spring. Cover corner cases and validations, discussing with the interviewer what real-world validations would be needed. No UI is required. Get the expected/core behavior working first, then move to good-to-have improvements. You're free to state and justify your own reasonable assumptions.

Round structure (120 minutes total)
Phase
Duration
Discussion & clarification
First 15 minutes — discuss the problem and clarify doubts with the interviewer.
Implementation
Next 90 minutes — code a working Java solution covering all requested scenarios and edge cases.
Testing & wrap-up
Final 15 minutes — run test cases and discuss the code.
Evaluation criteria
Criterion
What's assessed
Demoable code
The driver class runs and shows the full scenario end to end.
Thread safety
Concurrency and race conditions are handled correctly, especially around class capacity.
Approach
The overall solution strategy is sound and well-reasoned.
Data structure choice
Structures used fit the access patterns (lookups, capacity checks, bookings).
Optimization
Reasonable performance characteristics for the given operations.
Readability
Code is clear and easy to follow.
Extensibility
New requirements can be added without a rewrite.
Modularity
Responsibilities are cleanly separated across classes.
Exception handling
Invalid operations fail gracefully with clear errors.
Input validation
Inputs are validated appropriately at each API boundary.
Up next1/1
Part 2 · SDE-3+
←
← Prev Chapter
Car Pooling
5 min

Enroll in machine coding mastery series

₹30,000₹3,00090% OFF
Enroll Now →

Use code SOLID50 · 3 years · 40+ lessons

On this page
  • Objective
  • Functional Requirements
    • Part 1 — Admin Flows
    • Part 2 — Customer Flows
  • Example Usage
  • Guidelines