Another attempt at showing an incorrect behavior for the provided solution

inserting {8, 9} into {{1, 3}, {5, 7}, {9, 12}};
gives
{{1, 3}, {5, 7}, {8, 12}};

I believe the comparison on line 33 needs to be
while (i < intervals.size() && intervals[i].start < newInterval.end) {

to give the correct answer:
{{1, 3}, {5, 7}, {8, 9}, {9, 12}};


Course: Grokking the Coding Interview: Patterns for Coding Questions - Learn Interactively
Lesson: Insert Interval (medium) - Grokking the Coding Interview: Patterns for Coding Questions

If the end slots are not inclusive - IE - an interval from {8, 9} includes 9, then the visual aide here:

which shows the interval as non-inclusive, seems misleading to me.


Course: Grokking the Coding Interview: Patterns for Coding Questions - Learn Interactively
Lesson: Merge Intervals (medium) - Grokking the Coding Interview: Patterns for Coding Questions

Hi @Emily_Wagner,
In the given scenario of inserting {8, 9} into {{1, 3}, {5, 7}, {9, 12}} the correct answer is {{1, 3}, {5, 7}, {8, 12}} because there is overlapping at integer 9 and the problem statement mention that Display a list of non-overlapping intervals sorted by their start time. The following condition, which is also used in the code, is correct:
while (i < intervals.size() && intervals[i].start <= newInterval.end)
I hope this will help.

Hi @Emily_Wagner,
The illustration briefly explains the concept that we only merge sets if a start or end point lies between or at the start or end point of other sets. Edge-points are also inclusive while merging two sets.

OK - the instructions and examples do not specify this behavior, and the included image suggests the opposite of the desired behavior. You can incorporate or ignore that feedback.


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

Hi @Emily_Wagner,

Your feedback is highly appreciated. We will incorporate those changes into the course.
We hope Educative has inspired you to further your learning, and please drop us a note if you have any other questions or concerns :slightly_smiling_face:.