Data Structure | Leetcode Problems | Purpose | Operation |
---|---|---|---|
Priority Queue/Min-Heap | 253. Meeting Rooms II | 1.We need a way efficiently keep track of earliest ending time of meeting room we assigned already. 2.We need a efficient way to retrieve the previous meeting with earliest ending time. | 1.Insert current meeting into the min-heap with key, ending time or extract assigned meeting room with earliest ending time from min-heap. It takes O(log n) time better than manually iterating on every room that’s been allocated before, O(n). 2.We compare starting time of current meeting with the topmost element in the min-heap. It only takes O(1). 3.In short, we keep all the rooms in a min heap where the key for the min heap would be the ending time of meeting. |
Last active
April 30, 2020 15:51
-
-
Save liyunrui/79a3528a2f73d226f84144cd215ef603 to your computer and use it in GitHub Desktop.
Priority Queue/ Min-Heap
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment