- There are n seats in a coach of a train with only r seats in a row.
- One person can reserve up to 7 seats at a time.
- If person is reserving seats, the priority will be to book them in one row.
- If seats are not available in one row then the booking should be done in such a way that the nearby seats are booked.
- User can book as many tickets as s/he wants until the coach is full.
- Implement proper backend with use of database.
- Add Multiple trains and Coach in every train.
- Input required will only be the required number of seats. Example: 2 or 4 or 6 or 1 etc.
- Output should be seats numbers that have been booked for the user along with the display of all the seats and their availability status through color or number or anything else that you may feelfit.
- You need to write code (functions) as per the conditions and functionality mentioned above.
- You need to submit the database structure you’ll be creating as per your code.
- You need to host it on any of the free/paid platform so that you can provide as a working web URL for this problem.
- You need to send us the code a zip file for us to look at your code and evaluate the same. You can also send us GIT link for the same.
There are some seats already booked in that coach. So your code should be able to find the seats available and then book them.
• You can take appropriate assumptions, if any, and state them on top of the submission sheet. • Write a good functional and optimum code. • Try to use less variables.
I have used dynamic programming approach to store the state of booking of train coach into a lookup table and refer it later. This approach helped me to reduce the time complexity of booking seats to O((rxc)/2) which is roughly Half of Exponential complexity.