Grokking the Coding Interview: Patterns for Coding Questions
Ask Author
Back to course home

0% completed

Vote For New Content
To confirm, we can follow another similar approach to "Merge Intervals" with so...

Richard Yuan

Feb 6, 2022

To confirm, we can follow another similar approach to "Merge Intervals" with sorting removed by inserting the new interval into the list of intervals based on start value. So insert into the first index where new_interval[start] is greater than intervals[i][start]? We then perform the rest of the "Merge Intervals" logic to avoid having to set new_interval[start] = min(new_interval[start], intervals[i][start]).

2

0

Comments
Comments
C
Casey Park4 years ago

Do you think it is possible that you elaborate on this?

M
Matteo 2 years ago

This is what I did before I looked up the solution and unless I'm mistaken it is also in O(n) since we no longer need to do the sorting

On this page