The Question
CodingMinimum Hotel Rooms Required
Given two integer arrays
arrivals and departures representing the check-in and check-out times of guests at a hotel, calculate the minimum number of rooms required to accommodate all guests. A room can be reused immediately if a guest checks out at the same time another guest checks in (e.g., a checkout at time 5 and a check-in at time 5 do not overlap).
Constraints:
- 1 <= arrivals.length == departures.length <= 10^5
- 0 <= arrivals[i] < departures[i] <= 10^9
- The input arrays are not necessarily sorted.Java
Sweep Line
Two-pointer
Sorting