DrawCode Practice Problem

Merge Intervals

Given an array of intervals `intervals` where `intervals[i] = [start, end]`, merge all overlapping intervals.

Examples

Input

intervals = [[1,3],[2,6],[8,10],[15,18]]

Output

[[1,6],[8,10],[15,18]]

Constraints


Interactive Visualizer Workspace

Explore step-by-step interactive animations, memory state tracking, and live multi-language execution in DrawCode.

Launch Interactive Visualizer