#4 most askedVery commonMediumIntervals
Merge Intervals
New to Intervals? Learn it from scratch firstIntervals β
π’ Asked in real interviews
No reports yet. Were you asked this? Be the first to say where.Given a list of intervals [start, end], merge all overlapping intervals and return the result sorted by start.
[[1, 3], [2, 6], [8, 10], [15, 18]] β [[1, 6], [8, 10], [15, 18]]
π§ͺ Practice
Write your solution, then press Run tests. Explain your approach out loud as you go.
def merge(intervals):
pass
Output appears here. Press Run or Ctrl/β + Enter.
Try it first. Struggling for a few minutes is how it sticks.