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