Next Interval (hard)

Why are we popping the elements from maxStartHeaps ?
I cannot understand that particular part of the solution.
I get we are removing the first one, and then adding it back in the end, but what about subsequent ones ?

Type your question above this line.


Hello @Vashisht_Gupta,

As we have two conditions in the while loop. One is >= topEnd.first.end and other is !maxStartHeap.empty() there can be a case where both the conditions will be true, and if we don’t pop, the program will be stuck in a while loop.

I hope this helps.
Happy Learning