π’ PhonePe Machine Coding Round β SDE Interview Experience
Summary
I experienced a Machine Coding Round for an SDE-1 role at PhonePe, where I was tasked with designing a Fitness Class Booking System, and successfully implemented key features including user management, class scheduling, booking with waitlists, and concurrency handling, using OOP principles and in-memory storage.
Full Experience
Role: SDE-1
Platform: Onsite/Online (Coding Environment Provided)
Round Type: Machine Coding (Duration: 90β120 mins)
Language Used: Java
πΌ Problem Statement:
Design a Fitness Class Booking System with the following features:
π₯ User Management:
- Users can register/login with tier-based packages:
- Platinum β 10 classes
- Gold β 5 classes
- Silver β 3 classes
π Class Management (Admin Functionality):
- Create, schedule, and cancel fitness classes (e.g., Yoga, Gym)
- Each class has a capacity and scheduled time
π Booking Functionality:
- Users can book classes based on available slots and their tier limit
- If the class is full β Add to waitlist
- On cancellation, the first waitlisted user gets the slot
β Cancellation:
- Users can cancel up to 30 minutes before the class
- Cancelled bookings restore userβs quota
π Concurrency:
- Multiple users trying to book at the same time β Thread-safe booking logic was expected
π§ My Approach:
- Used OOP Design: Classes like
User,FitnessClass,BookingService, etc. - Followed Separation of Concerns using service classes
- Stored everything in-memory using HashMaps/List (no DB required)
- Used
synchronizedblocks for thread safety - Hardcoded the main flow (register, create class, book, cancel, etc.) for quick testing
β Features Implemented:
- User registration with package tiers
- Admin can schedule classes
- Class booking with capacity checks
- Waitlist promotion after cancellation
- Tier-wise booking limits
- Concurrency-safe booking
Feel free to ask if anyone wants the code or detailed breakdown. Hope this helps for your upcoming rounds! βοΈ
Interview Questions (1)
Design a Fitness Class Booking System with the following features:
π₯ User Management:
- Users can register/login with tier-based packages:
- Platinum β 10 classes
- Gold β 5 classes
- Silver β 3 classes
π Class Management (Admin Functionality):
- Create, schedule, and cancel fitness classes (e.g., Yoga, Gym)
- Each class has a capacity and scheduled time
π Booking Functionality:
- Users can book classes based on available slots and their tier limit
- If the class is full β Add to waitlist
- On cancellation, the first waitlisted user gets the slot
β Cancellation:
- Users can cancel up to 30 minutes before the class
- Cancelled bookings restore userβs quota
π Concurrency:
- Multiple users trying to book at the same time β Thread-safe booking logic was expected
Preparation Tips
π‘ Tips for Candidates:
- Think in real-world object models
- Start with core functionality, leave enhancements for later
- Keep code modular and readable
- Add comments to clarify assumptions and logic
- Donβt forget edge cases (cancelling, waitlist promotion)