Was asked question like this
We have a restraunt where there are unknown numbers of tables
People come in a group of size k and wait in the line.
Any group can decide to leave the waitline at any point of time.
Waiter comes with table size n we have to return the first largest group which fits the given table n.
Design a data structure and implement addGroup, removeGroup, selectGroupWas expected to create insertion and deletion in O(1) and selectGroup operation in O(log N)
Was able to come up with ds using hashed DLL for insertion and deletion in O(1) and binary search on the hashed LL for search
But could not code it up so got rejected.
Please let me know a better way out.
Thanks
Edit :-
As pointed out by @niketan21
I missed adding couple of things.
Yes, removeGroup() takes a unique id of a group to be removed, this was revealed in the later part of interview.
Found a similiar question asked before :- https://leetcode.com/discuss/interview-question/1779091/google-phone-interview-usa-restaurant-wait-list