You are given an array interval objects. Each interval is represented as a pair of integers, [check_in_day, check_out_day].
Your task is to determine the minimum number of rooms required to fulfill all the booking requirements.
You may assume that:
interval [start, end], start will always be strictly less than end.(8, 9) does not conflict with a meeting from (9, 10).Return the minimum number of rooms as an integer.
[ [1, 2], [3, 4] ]
1
Booking [1,2] uses a room from day 1 to day 2.
Booking [3,4] uses the same room from day 3 to day 4. Since there is no overlap, only one room is required.
[ [1, 3], [2, 4], [3, 5] ]
3
On day 1, booking [1,3] is active (1 room).
On day 2, bookings [1,3] and [2,4] are active (2 rooms).
On day 3, bookings [1,3], [2,4], and [3,5] are all active at the start of the day before [1,3] checks out (3 rooms).
Thus, a maximum of 3 rooms are needed concurrently.
[ [1, 10], [2, 3], [4, 5], [6, 7] ]
2
The booking [1,10] requires one room for a long duration. The other bookings [2,3], [4,5], and [6,7] can use a second room sequentially as they do not overlap with each other, but they all overlap with [1,10]. Therefore, two rooms are required.
[ [1, 2], [3, 4] ]
1