Carousell interview question

Write a function to merge intervals.