Google - L4 interview - phone screen
Anonymous User
5598

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 -

  1. Current waitlist - [4,2,3,6] - In order of their arrival, each element indicates the size of the group
  2. Customer group of size 5 enters the waitlist then updated waitlist would be - [4,2,3,6,5]
  3. 4th group(index 3) leaves the waitlist. Updated wailist - [4,2,3,5]
  4. findGroup for table size 3. output - group 2(index 1)
    eligible groups - 2(index 1),3(index 2) for tablesize 3 but since group of size 2 has arrived before group of size 3, return group of size

Help me with the most optimal solution.

Comments (29)