253.Meeting-Rooms-II
253. Meeting Rooms II
题目地址
https://leetcode.com/problems/meeting-rooms-ii/
题目描述
代码
Approach 1: Priority Queue
Complexity Analysis
Time Complexity: O_(_N_log_N).
There are two major portions that take up time here. One is
sorting
of the array that takes O_(_N_log_N) considering that the array consists of N elements.Then we have the
min-heap
. In the worst case, all N meetings will collide with each other. In any case we have N add operations on the heap. In the worst case we will have N extract-min operations as well. Overall complexity being (NlogN) since extract-min operation on a heap takes O_(log_N).
Space Complexity: O(_N) because we construct the
min-heap
and that can contain _N elements in the worst case as described above in the time complexity section. Hence, the space complexity is O_(_N).
Approach #2 Chronological Ordering
Last updated