Back to course home
0% completed
Vote For New Content
Instead of using max heaps, using min heaps would be more straightforward. When ...
Michelle Cheng
Aug 9, 2022
Instead of using max heaps, using min heaps would be more straightforward. When using max heaps, you may have to pop from the start heap multiple times to find the closest start, then add the last interval back in. With a minStartHeap and minEndHeap, the first cur_start >= cur_end and s_i != s_e is guaranteed to be the interval with the closest start value. Upon fulfilling this condition, pop from minEndHeap, and the next cur_end is guaranteed to be >= cur_start.
1
0
Comments
Comments
M
Michael Shum3 years ago
My initial approach used minHeaps too. seems like both solutions (using minHeap vs using maxHeap) work, just different nuances to both.
On this page