You are given meeting time intervals where intervals[i] = [start_i, end_i]. Each meeting uses one room for the entire half-open time range [start_i, end_i). Return the minimum number of rooms needed so every meeting can happen without conflict.
Input / output
intervals: int[][]Examples
intervals = [[0,30],[5,10],[15,20]] returns 2 because the meetings [0,30) and [5,10) overlap.intervals = [[7,10],[2,4]] returns 1 because the meetings do not overlap.intervals = [[1,5],[2,3],[3,6]] returns 2 because one room can host [2,3) then [3,6), while [1,5) still needs another room.Constraints
0 <= intervals.length <= 10^5intervals[i].length == 20 <= start_i < end_i <= 10^6Target complexity
O(n log n) time and O(n) extra space or better.Hints
Follow-up How would you modify the algorithm to return an actual room assignment for each meeting, not just the count?