Pregunta de entrevista de Amazon

Coding question about merging intervals with a twist.