Given an array of intervals where intervals[i] = [start_i, end_i], merge all overlapping intervals, and return an array of the non-overlapping intervals that cover all the intervals in the input.
Two intervals overlap if the start of one is less than or equal to the end of the other (and vice versa).
This is the foundational intervals problem. The key insight is to sort by start time first, then merge consecutive overlapping intervals by extending the end time.
Real-world analogy: Think of merging calendar events. If you have meetings from 9-10, 9:30-11, and 10:30-12, they can all be merged into a single block from 9-12 since they overlap.
intervals = [[1,3],[2,6],[8,10],[15,18]][[1,6],[8,10],[15,18]]intervals = [[1,4],[4,5]][[1,5]]intervals = [[1,4],[0,4]][[0,4]]1 <= intervals.length <= 10^4intervals[i].length == 20 <= start_i <= end_i <= 10^4Click "Run" to execute your code against test cases
Socratic guidance - I'll ask questions, not give answers