Pergunta de entrevista da empresa Amazon

Coding question about merging intervals with a twist.