Question seems really hard to me. I mean I get it but how many people would have gotten it in a typical 45 min interview setting?
Is this really a medium question?

@lekzeey
I have worked on some of the related problems. They were marked as "Hard".https://leetcode.com/problems/mergeintervals/
https://leetcode.com/problems/theskylineproblem/But once you captured the underlying idea, it is easy to come up with a reasonable solution. I guess that's the whole point of practicing on LeetCode.
There was a VERY good explanation for the skylineproblem, you can find the link below. Hope it would help you solve many of the "interval problems".https://briangordon.github.io/2014/08/theskylineproblem.html