educative.io

Educative

Why do we need to put the topStart back in the maxStartHeap? Can anyone give an example?

Also, why only put the 1st interval from maxStartHeap that satisfies maxStartHeap.peek()[0] >= topEnd condition back in the maxStartHeap? And not all the intervals that we are popping in the while loop while (maxStartHeap.length > 0 && maxStartHeap.peek()[0] >= topEnd) { … }

1 Like