Similar: https://leetcode.com/discuss/interview-question/4903609/Google-E4-Phone-Interview-or-Time-Intervals-with-Enough-Capacity/
You're a restaurant manager who's job is to find available time windows for seating N number of guest(s). Lets assume your restaruant is specified in the following way:
restaurant = {
'restaurant_start': 9,
'restaurant_end': 22,
'capacity': 5,
'reservations': [
{'start': 10, 'end': 14, 'ppl': 3},
{'start': 11, 'end': 13, 'ppl': 2},
{'start': 13.5, 'end': 15, 'ppl': 1},
{'start': 16, 'end': 20, 'ppl': 2}
]
}
Where restaurant_start and restaurant_end are the open and close times of the resturant, capacity is the maximum number people the restaurant can fit at any point, and reservations are existing reservations w/ guests (e.g ppl is the number of customers who are already at the restaurant at that time interval).
Write an algorithm that can output all available time intervals for seating an input N guests from restaurant open to close (e.g [[9,11],....]]). Assume your input to the function is in the format of the restaurant dictionary object specified above along with a parameter N indicating the number of people to seat.
Was not able to solve the problem on my own, the interviewer gave hints but still couldn't complete it in time to run the testcases