Skip to content
DSA Visualizerpreview

Merge intervals

Sort by start; each interval either stretches the current block or starts a new one.

O(n log n) time · O(n) space

Intervals8-10, 1-3, 2-6, 15-16, 9-12, 5-7

Merge every overlap in 8–10, 1–3, 2–6, 15–16, 9–12, 5–7.

Intervals 8–10, 1–3, 2–6, 15–16, 9–12, 5–7. Merged so far: none.
  • compare
  • swap or write
  • settled

1 / 9

Speed

Space play · ← → step · Home End jump · drag the strip to scrub