Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to sort the start times of meetings.
DSA Go
sort.Slice(intervals[1], func(i, j int) bool { return intervals[i].Start < intervals[j].Start })
Attempts:
3 left
💡 Hint
Common Mistakes
Using (0) or [0] which are invalid for sorting the whole slice.
Trying to sort intervals without slicing causes errors.
✗ Incorrect
Using [:] slices the entire intervals slice to sort by start times.
2fill in blank
mediumComplete the code to push the end time of the first meeting into the heap.
DSA Go
heap.Push(&minHeap, intervals[0][1])
Attempts:
3 left
💡 Hint
Common Mistakes
Pushing start time instead of end time.
Using incorrect indexing like [1] or [0] without field.
✗ Incorrect
We push the end time to track when the room becomes free.
3fill in blank
hardFix the error in comparing the current meeting start time with the earliest end time in the heap.
DSA Go
if intervals[i].Start [1] minHeap[0].(int) {
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<=' causes wrong logic for room reuse.
Using '==' misses cases where start is after end.
✗ Incorrect
If current start is greater or equal, room is free to reuse.
4fill in blank
hardFill the blank to pop the earliest end time and push the current meeting's end time.
DSA Go
heap.Pop(&minHeap)
heap.Push(&minHeap, intervals[i][1])Attempts:
3 left
💡 Hint
Common Mistakes
Pushing start time instead of end time.
Using wrong indexing like [1] or [0].
✗ Incorrect
Pop frees a room, then push current meeting's end time to track usage.
5fill in blank
hardFill all three blanks to return the minimum number of rooms needed after processing all meetings.
DSA Go
return [1](minHeap)
Attempts:
3 left
💡 Hint
Common Mistakes
Using cap() returns capacity, not current size.
Using copy() or append() are unrelated here.
✗ Incorrect
The heap size shows how many rooms are used simultaneously.
