Merge Intervals Visualizer
Sort intervals by start value, scan each candidate, and watch overlapping ranges collapse into the final merged output.
Interval input
Step controls
Step 1 of 6: Sort intervals by start value before scanning from left to right.
Merge intervals diagram
Sort intervals by start value before scanning from left to right.
No active interval in this step.
No candidate interval in this step.
Committed output
No intervals have been committed to the output yet.
Result
What is a Merge Intervals Visualizer?
A merge intervals visualizer shows how overlapping ranges are sorted, compared, merged, and added to the final output.
This tool accepts LeetCode-style interval input such as [[1, 3], [2, 6], [8, 10], [15, 18]]. It sorts by start value, keeps a current interval, and steps through each overlap check.
For the full cluster of related tools, browse the Data Structure Visualizers hub.
How to use this merge intervals visualizer
- Paste intervals in array, comma-separated, or line-separated format.
- Step through the sorted intervals from left to right.
- Watch whether each candidate overlaps the current interval.
- Inspect the committed output intervals and the active interval.
- Run to the end to see the final merged result.
Merge intervals algorithm
The standard algorithm sorts intervals by their start value. Then it scans once. If the next interval starts before or at the current interval end, the intervals overlap and the current end becomes the larger end. Otherwise, the current interval is committed to the output and the next interval becomes current.
The time complexity is O(n log n) because of sorting, and the scan after sorting is O(n).
Compare this page with the Interval Tree Visualizer, Sorting Algorithm Visualizer, Two Pointers Visualizer, and Prefix Sum Visualizer.