Merge Intervals

0Medium

Merge Intervals

Given an array of intervals, merge all overlapping intervals and return an array of non-overlapping intervals covering all input intervals.

Example 1:

Input: [[1,3],[2,6],[8,10],[15,18]] Output: [[1,6],[8,10],[15,18]]

Example 2:

Input: [[1,4],[4,5]] Output: [[1,5]]

Example 3:

Input: [[1,4],[2,3]] Output: [[1,4]]

JR

Jnaneshwara Reddy Satti

Builder · ClearCode

Hi — I'm a 21yo CS grad from India. I built ClearCode while recovering from a surgery, because I genuinely believe DSA should be visual, free, and accessible to everyone. No VC funding. No team. Just me, my laptop, and a lot of chai. ☕

If ClearCode helped you understand even one concept — consider supporting it. Every rupee keeps the servers running and new videos coming.

Support via Razorpay
Support ClearCode ☕