Given a collection of intervals, merge all overlapping intervals and return an array of the non-overlapping intervals that cover all the intervals in the input.
Input
A list of intervals, where each interval is represented as a list of two integers [start, end].
Output
A list of merged intervals, where each interval is represented as a list of two integers.
Constraints
1 <= intervals.length <= 10^4
0 <= intervals[i][0] <= intervals[i][1] <= 10^4
Function Signature
defmerge_intervals(intervals):
Interviewer
Whenever you're ready, walk me through your approach or go straight to the code. The requirements are in the Question tab.