Merge overlapping intervals