Message on Whatsapp 8879355057 for DSA(OA + Interview) + Fullstack Dev Training + 1-1 Personalized Mentoring to get 10+LPA Job
0 like 0 dislike
914 views
in Interview-Experiences by Expert (34,270 points) | 914 views

1 Answer

0 like 0 dislike
The question was to book a table in restaurants. Its LC Medium with a LC hard follow-up. This is like a design question. He asked me which all APIs I provide and what data structures. Then he said he is satisfied the way I designed but don't need that much information. So we will proceed with adding 3 interfaces: add a booking, delete a booking, assign a booking.
I used a map with customer size and vector of booking ids. When a table is free,
get lower_bound of map which will return the vector booking ids.
If the map entry size is greater than table size, return the prev map entry.
Pop the front of vector and return it.

 

This solution was accepted and he asked me to proceed with coding. The follow-up was how to do if table size is also configured. I suggested to keep an availability list and free list as well. So we can assign the best one based on the customer size.

 

In this round as well, we didn't discuss about time complexities. There was enough time at the end but I forgot to mention about time complexity and he too didn't ask about it.
by Expert (34,270 points)

Get best answers to any doubt/query/question related to programming , jobs, gate, internships and tech-companies. Feel free to ask a question and you will receive the best advice/suggestion related to anything you ask about software-engineering , development and programming problems .