I had Google phone screening round recently. Below is the question asked
Design a data structure for restaurant customers waitlsit which should support
a. New customer groups can be added to waitlist
b. A waiting customer group can leave at any time
c. Given a tableSize, you need to find the right customer group which can be assigned to the input table. A group is eligible for a table if it's size is <= tableSize and among those groups you need to select the one who has arrived first.
For example -
Help me with the most optimal solution.