educative.io

Educative

Heap issue in https://www.educative.io/courses/grokking-the-coding-interview/JQMAmrVPL7l

The heappush in line number 25 will bring meeting with smallest starttime on top not wrt to endtime.

add the current meeting into min_heap

heappush(minHeap, meeting)

Therefore, we need to push and pop in heap only the meeting end time not the tuple.
Is this correct ?

I think so too. We should only push meeting end_time. But it works because they overwrote the __ lt __ in the Meeting class to use the end time as the key for the minHeap.


Course: Grokking the Coding Interview: Patterns for Coding Questions - Learn Interactively
Lesson: Solution Review: Problem Challenge 1 - Grokking the Coding Interview: Patterns for Coding Questions

Hi @Anirban_Laha
Yes, it’s correct.

1 Like

Hi @Ankit_Nayak
Exactly.

1 Like