Microchip Technology interview question

Medium leetcode question, merge intervals