Carousell Interview Question

Write a function to merge intervals.